I assume you are using Ubuntu 16.04 as your server OS. I also assume you have already installed it.

Start with getting up to date.

First of all, startup your server console, update and upgrade apt-get:

sudo apt-get update
sudo apt-get upgrade

First things first, we need Nginx.

sudo apt-get install nginx

We use PHP FPM to run PHP on our nginx server;

sudo apt-get install php-fpm

At this exact moment we can already see if nginx is working. Navigate in your browser to http://your-domain-or-ip-address.extension and you should see the following screen:

Nginx confirmation page

Nginx confirmation page

If it is working, awesome. If it ain’t, post a comment, I will try to help you.

Next step, make a new vhost and open it

sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/yourname
sudo nano /etc/nginx/sites-available/yourname

Change it as follows, this configuration already helps us with using Laravel without a .htaccess (as that only works with Apache)

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/chilion/public;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name chilion.nl

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        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;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one

        location ~ /\.ht {
                deny all;
        }
}

Next, enable this website

ln -s /etc/nginx/sites-available/yourname /etc/nginx/sites-enabled/yourname

At this moment we need to secure our lives by uncommenting and changing a line.

sudo nano /etc/php/7.0/fpm/php.ini

Find the following line (hint: CTRL+W)

;cgi.fix_pathinfo=1

And change that to

cgi.fix_pathinfo=0

And why?

This is an extremely insecure setting because it tells PHP to attempt to execute the closest file it can find if the requested PHP file cannot be found. This allows users to send PHP requests in a way that would allow them to execute any scripts on the server.

Nginx works!

Next, MariaDb!

Go to this link: https://downloads.mariadb.org/mariadb/repositories/

  • Here you will select your Linux distribution, in this tut we are using Ubuntu.
  • On the second box the version, 16.04
  • Third box, select latest version.
  • In the last box you can select your preferred mirror, any will do.

When everything is selected, the commands to execute will popup, execute them ;-)

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ams2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu xenial main'

When you’ve ran the commands, we will start installing MariaDB.

sudo apt-get update
sudo apt-get install mariadb-server
sudo apt-get install php-mysql

 

Almost there, Composer!

We need Composer, it comes in damn handy, so lets install it.

sudo apt-get install composer

 

Last required thing!

We of course need some php extensions to get Laravel working nicely:

sudo apt-get install php7.0-mbstring
sudo apt-get install php-xml
 sudo apt-get install php7.0-zip 

Last mile, GIT

Everyone is using GIT these days, so lets install it. This is not required for your server to work of course.

sudo apt-get install git

Thats it for today, thanks for reading! Problems? Comment and I will try to help!