Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vichetuc/1e4ef95b8a96b679058ab730d8da6435 to your computer and use it in GitHub Desktop.
Save vichetuc/1e4ef95b8a96b679058ab730d8da6435 to your computer and use it in GitHub Desktop.

Revisions

  1. @santoshachari santoshachari revised this gist Jun 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Laravel PHP7 LEMP AWS.md
    Original file line number Diff line number Diff line change
    @@ -176,5 +176,5 @@ Test PHP version
    php -v
    ```

    ### Setup additional hosts
    ### How to Setup additional hosts?
    This is covered in [this gist](https://gist.github.com/santoshachari/8238a7a4e7132d3c86a8720a81cd9fa1). Both gists were written in continuation.
  2. @santoshachari santoshachari revised this gist Apr 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Laravel PHP7 LEMP AWS.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version.
    #Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version.
    This tutorial is the improvised verision of this [tutorial on Digitalocean](https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04) based on my experience.

    ## Install PHP 7 on Ubuntu
  3. @santoshachari santoshachari revised this gist Apr 19, 2017. No changes.
  4. @santoshachari santoshachari revised this gist Dec 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Laravel PHP7 LEMP AWS.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ sudo apt-get install -y language-pack-en-base
    sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install zip unzip
    sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql php7.0-zip
    sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql php7.0-zip php7.0-gd
    sudo apt-get install nginx git
    ```

  5. @santoshachari santoshachari revised this gist Nov 28, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Laravel PHP7 LEMP AWS.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ sudo apt-get install -y language-pack-en-base
    sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install zip unzip
    sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql
    sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql php7.0-zip
    sudo apt-get install nginx git
    ```

  6. @santoshachari santoshachari renamed this gist May 21, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @santoshachari santoshachari revised this gist May 21, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Instructions.md
    Original file line number Diff line number Diff line change
    @@ -177,4 +177,4 @@ php -v
    ```

    ### Setup additional hosts
    This is covered in (this gist)[https://gist.github.com/santoshachari/8238a7a4e7132d3c86a8720a81cd9fa1]. Both gists were written in continuation.
    This is covered in [this gist](https://gist.github.com/santoshachari/8238a7a4e7132d3c86a8720a81cd9fa1). Both gists were written in continuation.
  8. @santoshachari santoshachari revised this gist May 21, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Instructions.md
    Original file line number Diff line number Diff line change
    @@ -174,4 +174,7 @@ sudo rm -rfv <folder_name>
    Test PHP version
    ```
    php -v
    ```
    ```

    ### Setup additional hosts
    This is covered in (this gist)[https://gist.github.com/santoshachari/8238a7a4e7132d3c86a8720a81cd9fa1]. Both gists were written in continuation.
  9. @santoshachari santoshachari revised this gist May 21, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Instructions.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql
    sudo apt-get install nginx git
    ```

    Important packages of Laravel
    Important packages for Laravel
    ```
    sudo apt-get install mcrypt php7.0-mcrypt
    sudo apt-get install -y php7.0-mbstring php7.0-xml --force-yes
  10. @santoshachari santoshachari revised this gist May 21, 2016. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions Instructions.md
    Original file line number Diff line number Diff line change
    @@ -158,4 +158,20 @@ sudo chmod -R 775 /var/www/laravel/storage
    ### Finish
    Check your site by `http://server_domain_or_IP` and it should show you "Laravel" homepage.

    ### Other commands of use.

    Installed a package that you don't need? Use the following commands to remove the package.
    ```
    sudo apt-get purge <package name>
    sudo apt-get autoremove --purge
    ```

    Use following command to remove a folder and it's contents
    ```
    sudo rm -rfv <folder_name>
    ```

    Test PHP version
    ```
    php -v
    ```
  11. @santoshachari santoshachari revised this gist May 21, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Instructions.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version.
    This tutorial is the improvised verision of this: https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04 based on my experience.
    This tutorial is the improvised verision of this [tutorial on Digitalocean](https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04) based on my experience.

    ## Install PHP 7 on Ubuntu
    Run the following commands in sequence.
    @@ -105,6 +105,10 @@ server {
    }
    }
    ```
    Notice the difference:
    - `try_files $uri $uri/ =404;` has been changed to `try_files $uri $uri/ /index.php?$query_string;`
    - and ` location ~ \.php$ { ... }` block has been added.

    Restart nginx.
    ```
    sudo service nginx restart
  12. @santoshachari santoshachari created this gist May 21, 2016.
    157 changes: 157 additions & 0 deletions Instructions.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,157 @@
    #Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version.
    This tutorial is the improvised verision of this: https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04 based on my experience.

    ## Install PHP 7 on Ubuntu
    Run the following commands in sequence.
    ```
    sudo apt-get install -y language-pack-en-base
    sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install zip unzip
    sudo apt-get install -y php7.0 php7.0-fpm php7.0-mysql
    sudo apt-get install nginx git
    ```

    Important packages of Laravel
    ```
    sudo apt-get install mcrypt php7.0-mcrypt
    sudo apt-get install -y php7.0-mbstring php7.0-xml --force-yes
    ```

    Some Optional ones
    ```
    sudo apt-get install php7.0-curl php7.0-json
    ```

    **NOTE:** You can use the following command to list available PHP 7.0 packages:
    ```
    sudo apt-cache search php7-*
    ```
    ## Modify the PHP Configuration
    Run the following command to go to php.ini
    ```
    sudo nano /etc/php/7.0/fpm/php.ini
    ```
    And uncomment and fix `cgi.fix_pathinfo` to
    ```
    cgi.fix_pathinfo=0
    ```
    Restart PHP 7.0 FPM
    ```
    sudo service php7.0-fpm restart
    ```

    ## Configure Nginx for Laravel
    I am going to setup using a blank latest version of Laravel. This would installed in `/var/www/laravel` folder.

    Run the following in terminal:
    ```
    sudo mkdir -p /var/www/laravel
    ```

    Next, we are going to modify the nginx's default configuration file: `/etc/nginx/sites-available/default`. But before that, just make a backup of the file:
    ```
    sudo mkdir ~/Backups
    sudo cp /etc/nginx/sites-available/default ~/Backups/default
    ```

    Use the following command to edit the file
    ```
    sudo nano /etc/nginx/sites-available/default
    ```

    Next modify `default` from this:
    ```
    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    root /usr/share/nginx/html;
    index index.html index.htm;
    server_name localhost;
    location / {
    try_files $uri $uri/ =404;
    }
    }
    ```
    to this:
    ```
    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    root /var/www/laravel/public;
    index index.php index.html index.htm;
    # Make site accessible from http://localhost/
    server_name <Your Domain name / Public IP Address>;
    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$query_string;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    }
    location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    ```
    Restart nginx.
    ```
    sudo service nginx restart
    ```

    If all was configured well, you'd see no error.

    ## SWAP file (Optional)
    Swap files would help in cases where your server might run out of memory.

    ```
    sudo fallocate -l 1G /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    ```
    ## Install Composer and Laravel

    Use the following commands to install composer and make it available across all folders.

    ```
    cd ~
    curl -sS https://getcomposer.org/installer | php
    sudo mv composer.phar /usr/local/bin/composer
    ```
    Test by `composer` command to see if it was installed correctly.

    Install laravel by using the following command.
    ```
    sudo composer create-project laravel/laravel /var/www/laravel
    ```
    In case it throws out errors due to missing packages, find the package name using
    ```
    sudo service php7.0-fpm restart
    ```
    and then remove and create the folder before running the composer create-project again.
    ```
    sudo rm -rf /var/www/laravel
    sudo mkdir /var/www/laravel
    ```

    ## Setting the permissions right for the Laravel folders.
    ```
    sudo chown -R :www-data /var/www/laravel
    sudo chmod -R 775 /var/www/laravel/storage
    ```

    ### Finish
    Check your site by `http://server_domain_or_IP` and it should show you "Laravel" homepage.