# Install software-properties-common package to give us add-apt-repository package sudo apt-get install -y software-properties-common # Install latest nginx version from community maintained ppa sudo add-apt-repository ppa:nginx/stable # Update packages after adding ppa sudo apt-get update # Install nginx sudo apt-get install -y nginx # Check status sudo service nginx # Start nginx if it is not already running sudo service nginx start # Add Repository which gives us the latest php version 7.2 sudo add-apt-repository ppa:ondrej/php # Lets now check what is the latest PHP version available now after the repository is added sudo apt-cache show php # Lets now install php7.2 and some important modules which we will need. sudo apt-get install php7.2-cli php7.2-fpm php7.2-curl php7.2-gd php7.2-mysql php7.2-mbstring php7.2-xml zip unzip # Once done all basic modules will be installed now, lets check the version now php -v # Lets also check if the PHP7.2-FPM is running, if not start it sudo service php7.2-fpm status sudo service php7.2-fpm start # (if the service isn't running already) # Let set php ;fix_pathinfo=1 to fix_pathinfo=0 sudo nano /etc/php/7.2/fpm/php.ini # After set php fix_pathinfo restart php sudo service php7.2-fpm restart # Install Mysql server sudo apt-get install mysql-server # Secure Mysql installation sudo mysql_secure_installation # Open nginx config file sudo nano /etc/nginx/sites-available/default # Setting nginx server block server { listen 80; server_name example.com; root /var/www/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$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } } # Test nginx configuration file sudo nginx -t # Then reload nginx for making change sudo systemctl reload nginx # Create swap file sudo fallocate -l 1G /swapfile sudo mkswap /swapfile sudo swapon /swapfile # Install Composer curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer # Initial Git cd /var/www/html/ git init git remote add production {ssh} git pull # Install vendor via composer composer install --optimize-autoloader --no-dev # Set permission for storage folder sudo chown -R :www-data /var/www/html sudo chmod -R 775 /var/www/html/storage sudo chmod -R 775 /var/www/html/bootstrap/cache # Set permission for upload folder sudo chown -R :www-data /var/www/html/public/folder # Create Database mysql -u root -p CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; exit # Create .env file cp .env.example .env nano .env # Optimize Laravel php artisan key:generate php artisan config:cache # Migrate Database php artisan migrate # Install phpMyadmin (Optional) https://www.digitalocean.com/community/questions/phpmyadmin-or-alternative-for-php7-nginx-mysql-5-7-ubuntu-16-04 # tutorial sudo apt-get install phpmyadmin # phpMyadmin Nginx Block location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { root /usr/share/; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } sudo ln -s /usr/share/phpmyadmin /var/www/html/public # Set file upload size sudo nano /etc/nginx/nginx.conf client_max_body_size 32M; service nginx reload