The installation of a server LEMP Linux + Nginx + MySQL + PHP might be more useful and efficient than an Apache (server LAMP).

Nginx installation

It will be essential to know the machine’s IP address to install from ifconfig.

 ifconfig eth0 | grep inet | awk '{ print $2 }'

From your system on Debian 8, we install nginx via the command :

sudo apt-get update
sudo apt-get install nginx

Your server nginx is now operational and available except if a rule prevent the streams HTTP and in this case, you have to check netfilter (iptables / ufw).


MySQL installation

Then, you need to install MySQL via the following command :

 apt-get install mysql-server

During the installation, you will be asked to choose a password root.

It is advisable to carefully choose your password preferably alphanumerical and including special characters.

To proceed with the installation, the following command has to be executed :


Enter your password root when requested and confirm the four following questions with yes :

 Enter current password for root (enter for none):
    OK, successfully used password, moving on...

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

PHP installation

Since Nginx does not contain PHP natively, it is important to install the PHP process manager called PHP FPM (FastCGI Process Manager) :

sudo apt-get install php5-fpm php5-mysql

Then, we are going to change the PHP configuration by changing the cgi.fix_pathinfo variable value to 1 or simply un-comment the line :

vim /etc/php5/fpm/php.ini 


Finally, we restart the PHP service :

systemctl restart php5-fpm

Nginx configuration

Now, we are going to change our default vhost so that Nginx uses the PHP processor :

vim /etc/nginx/sites-available/default

The red elements need to be added to the default vhost file :

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_address_IP;

    location / {
        try_files $uri $uri/ =404;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php5-fpm.sock;

    location ~ /\.ht {
        deny all;

Now, we need to check the Nginx configuration then reload the service and in case of error, we would have to review the previous configured file :

nginx -t

nginx -s reload


To conclude, we are going to test pour LEMP server with a page phpinfo :

echo "<php phpinfo(); >" > /var/www/html/phpinfo.php

The result is available from the url http://server_domain_or_address_IP/phpinfo.php and it leads to the following result :

From now on, your LEMP server is operational and will allow you performance enhancements, especially in terms of requests number compared to a LAMP server on Apache.