Skip to content

Instantly share code, notes, and snippets.

@harimau99
Forked from jay7793/Instruction.sh
Created June 26, 2019 11:47
Show Gist options
  • Save harimau99/5158b1c7ee0d89cd646d1f295e15bb2f to your computer and use it in GitHub Desktop.
Save harimau99/5158b1c7ee0d89cd646d1f295e15bb2f to your computer and use it in GitHub Desktop.

Revisions

  1. @jay7793 jay7793 revised this gist Mar 4, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Instruction.sh
    Original file line number Diff line number Diff line change
    @@ -131,6 +131,7 @@ php artisan config:cache
    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
    @@ -149,6 +150,8 @@ location /phpmyadmin {
    }
    }

    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;
  2. @jay7793 jay7793 revised this gist Aug 16, 2018. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions Instruction.sh
    Original file line number Diff line number Diff line change
    @@ -72,10 +72,9 @@ server {
    error_page 404 /index.php;

    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
  3. @jay7793 jay7793 revised this gist Aug 16, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Instruction.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ sudo add-apt-repository ppa:ondrej/php
    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 zip unzip
    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
  4. @jay7793 jay7793 revised this gist Aug 16, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Instruction.sh
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ sudo apt-get install mysql-server
    sudo mysql_secure_installation

    # Open nginx config file
    sudo nano /etc/nginx/site-available/default
    sudo nano /etc/nginx/sites-available/default

    # Setting nginx server block
    server {
  5. @jay7793 jay7793 renamed this gist Aug 15, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. @jay7793 jay7793 created this gist Aug 15, 2018.
    156 changes: 156 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,156 @@
    # 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 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/site-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$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include 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)
    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/;
    }
    }

    # Set file upload size
    sudo nano /etc/nginx/nginx.conf
    client_max_body_size 32M;
    service nginx reload