I assume you are using Ubuntu 14.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 php5-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, configure Nginx and PHP5-FPM. Fire up the config file of nginx:

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

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

server {
   listen 80 default_server;
   listen [::]:80 default_server ipv6only=on;

    root /var/www;
    server_name test.superbuddy.nl;
    index index.php;    

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

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

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    location ~/\.ht {
        deny all;
    }

}

Next, open up the php5-fpm configuration file:

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

It might work already, none the less you should check and find the following and eventually change it.

cgi.fix_pathinfo=0 #originally this is 1, make it 0

Save the file and open the next

sudo nano /etc/php5/fpm/pool.d/www.conf

Find and change listen to the value that is in the server block configuration file:

listen = /var/run/php5-fpm.sock

Restart both:

sudo service php5-fpm restart
sudo service nginx restart

If you didn’t have any php files in your root it becomes time to do this and test them out. The same url applies.

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, 14.04 “Trusty”.
  • 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 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.i3d.net/pub/mariadb/repo/10.1/ubuntu trusty main'

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

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

Almost there, Composer!

We need cUrl for Laravel later and for Composer it comes in damn handy, so lets install it.

sudo apt-get install php5-cli
sudo apt-get install php5-mysql
sudo apt-get install curl
sudo apt-get install php5-curl

Get Composer with Curl:

curl -sS https://getcomposer.org/installer | php

Move it to our PATH so you can use it Globally. (Not required)

mv composer.phar /usr/local/bin/composer

Last required thing!

We of course need Mcrypt to get Laravel to work nicely:

apt-get install php5-mcrypt

Create symlink to mods-available

ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini

Enable It.

php5enmod mcrypt

Restart php-fpm

service php5-fpm restart

Restart nginx

sudo service nginx restart

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!