LEMP Linux Nginx MariaDB Php Phpmyadmin on Debian Jessie

lemp_deb

Here’s a look at how I configured a LEMP server on Debian Jessie

Install nginx using command :

sudo apt-get install nginx
sudo apt-get install php5 php5-fpm php5-mysql

This location will be your Document Root in the nginx virtual configuration file later on. By adding a -p to the line of code, the command automatically generates all the parents for the new directory.

sudo mkdir -p /var/www/wordpress.dev/www

We need to grant ownership of the directory to the right user, instead of just keeping it on the root system. You can replace the “www-data” below with the appropriate username.

sudo chown -R www-data:www-data /var/www/wordpress.dev/www
sudo vim /var/www/wordpress.dev/www/index.html

We can add some text to the file so we will have something to look at when the the site redirects to the virtual host.

<html>
  <head>
    <title>wordpress.dev</title>
  </head>
  <body>
    <h1>Success: You Have Set Up a Virtual Host</h1>
  </body>
</html>

The next step is to create a new file that will contain all of our virtual host information.

vi /etc/nginx/sites-available/wordpress.dev
server {
    root /var/www/wordpress.dev/www;
    index index.html index.htm index.php;

    access_log /var/log/nginx/wp.dev.access.log;
    error_log /var/log/nginx/wp.dev.error.log;

    server_name wordpress.dev;

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

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

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

Make a symbolic link to /site-enabled to enable it

sudo ln -s /etc/nginx/sites-available/wordpress.dev /etc/nginx/sites-enabled/wordpress.dev

To check if syntax works

sudo nginx -t

then

sudo service nginx restart

Now install MariaDB

apt-get install mariadb-server mariadb-client

check it

mysql -V

secure it

mysql_secure_installation

I must stress that this is not recommended for a production environment.

To avoid  this error in phpmyadmin

ERROR 1698 (28000): Access denied for user 'root'@'localhost'
mysql -u root -p

At the mysql prompt enter the following:

use mysql;
update user set plugin='' where User='root';
flush privileges;
exit

and phpMyAdmin

sudo apt-get install phpmyadmin