Skip to content

Instantly share code, notes, and snippets.

@dvigne
Last active December 28, 2017 09:13
Show Gist options
  • Save dvigne/57908c30473782307810d5b3c5318176 to your computer and use it in GitHub Desktop.
Save dvigne/57908c30473782307810d5b3c5318176 to your computer and use it in GitHub Desktop.

Quick note, be sure to change the sites name test to the name of your app

Update The Servers Definitions and Software

sudo apt update
sudo apt upgrade

Installing MySQL

sudo apt install mysql-server

Installing Nginx

sudo apt install nginx

Instaling PHP

sudo apt install php-fpm php-myql php-mbstring php-zip php-xml

Configure PHP

/etc/php/7.0/fpm
sudo vi php.ini
cgi.fix_pathinfo=0

Installing Composer

sudo apt install composer

Configuring Composer

composer global require "laravel/installer"

Configuring Linux

sudo vi ~/.profile

append $HOME/.config/composer/vendor/bin to your $PATH variable

PATH="$HOME/bin:$HOME/.local/bin:$PATH:$HOME/.config/composer/vendor/bin"	

Go to the directory where you want to store the site e.g. /var/www/html and type the following commands to create the Laravel project directory

laravel new test
cd test
cp .env.example .env
php artisan key:generate

You also need to configure the proper directory permissions

cd /var/www/html/
sudo chown -R -v yourusername:www-data test
chmod -R -v 750 test
cd test
chmod 770 storage
chmod 770 bootstrap/cache

Configuring Nginx

Make a new configuration file

cd /etc/nginx/sites-available
sudo cp default test
sudo vi test

Change the following lines

root "/var/www/html/test/public"

index index.html index.htm index.nginx-debian.html index.php;

server_name test.app www.test.app

try_files $uri $uri/ /index.php?$query_string;

location ~ \.php$ {
           include snippets/fastcgi-php.conf;
#
    #       # With php7.0-cgi alone:
#       fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
           fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

Enable the site

sudo ln -s /etc/nginx/sites-available/test /etc/nginx/sites-enabled/test

and if the default sites is still enabled

sudo rm /etc/nginx/sites-enabled/default

and restart the server

sudo service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment