Last active
March 31, 2021 16:06
-
-
Save mehdi89/03e9a80f6fc996eccd7ec3b5f875ee43 to your computer and use it in GitHub Desktop.
Deploying simple Laravel Application in AWS with Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo add-apt-repository ppa:nginx/stable -y | |
sudo add-apt-repository ppa:ondrej/php -y | |
sudo apt update | |
sudo apt-get install nginx -y | |
sudo apt-get install zip unzip php7.4 php7.4-mysql php7.4-fpm php7.4-xml php7.4-gd php7.4-opcache php7.4-mbstring php7.4-zip -y | |
#install composer | |
curl -sS https://getcomposer.org/installer | php | |
sudo mv composer.phar /usr/local/bin/composer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /var/www/html | |
sudo composer create-project laravel/laravel tutorial --prefer-dist | |
sudo chown -R www-data:ubuntu tutorial/ | |
sudo chmod -R 775 tutorial/ | |
#cd /etc/nginx/sites-available | |
#sudo nano tutorial.conf | |
#copy paste the content of below nginx config file | |
#cd /etc/nginx/sites-enabled | |
#sudo rm -rf default | |
#sudo ln -s ../sites-available/tutorial.conf . | |
#sudo nginx -t | |
#sudo service nginx restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo fallocate -l 1G /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
#https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04#create-swap-file-(optional) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name example.com; | |
root /var/www/html/tutorial/public; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Content-Type-Options "nosniff"; | |
index index.html index.htm index.php; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
error_page 404 /index.php; | |
location ~ \.php$ { | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.(?!well-known).* { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment