Install WordPress on Debian 7 LEMP Stack

By | November 24, 2014

WordPress is the most popular Open Source CMS/Blogging platform today. It is based on PHP and uses MySQL database. WordPress powers more than 20% of the top 10 million websites. For more information please visit the wordpress website

Because it is based on PHP and uses MySQL database to store files, it is but natural that it needs a LAMP (Linux, Apache, MySQL,PHP) stack to get up and running.

Let’s see how install WordPress on Debian 7 LEMP stack (Linux,Nginx,MariaDB.PHP5-FPM). I will not be going deep in setting up a LEMP stack in Debian 7, as I have covered that part in another post. You can find it HERE.

1) Create the MariaDB database for wordpress and grant privileges for the wordpress user

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wpuser_passwd';
MariaDB [(none)]> \q

Provide your own password in place of ‘wpuser_passwd’.

2) Download WordPress tarball, extract it and put it in the web-root

Navigate to “/tmp” and download it and extract it.

 wget && tar -xf latest.tar.gz

Once extracted, a directory/folder by name wordpress is created in “/tmp”. Copy it to the webroot of Nginx, and give the ownership of of the wordpress directory to nginx. In my case the Nginx webroot is “/usr/share/nginx”.

sudo cp -R wordpress /usr/share/nginx/ && sudo chown -R nginx.root /usr/share/nginx/wordpress/

3)Configuring Nginx to serve our wordpress site 

Create file “wordpress.conf” with contents as described below inside nginx main configuration directory from where the sites are served

sudo nano /etc/nginx/conf.d/wordpress.conf
server {
 listen 80;
 root /usr/share/nginx/wordpress;
 index index.php index.html index.htm;
 location / {
 try_files $uri $uri/ /index.php?q=$uri&$args;
 error_page 404 /404.html;
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 root /usr/share/nginx/html;
 # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
 location ~ \.php$ {
 try_files $uri =404;
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;

Change the “server_name” to your server’s FQDN or ip address. In my case my Server FQDN is

Restart Nginx

service nginx restart

4) Installing WordPress

Navigate inside the directory “/usr/share/nginx/wordpress”. copy the file “wp-config-sample.php” as “wp-config.php”

cp -R wp-config-sample.php wp-config.php

Once copied, update the file with your wordpress database details as created above. The changes will be made in the following sections in the file:

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wpuser');
/** MySQL database password */
define('DB_PASSWORD', 'wpsuer_passwd');
/** MySQL hostname */
define('DB_HOST', 'localhost');

Now open your web browser and type your Server’s FQDN or ip address. In my case it is You will see the wordpress installer.

Screenshot 1


Screenshot 2

Once done, you will be presented with you login screen. Use the username and password as given during the installation process. You will have access to your Dashboard and carry on with further configuration.

You can now access the blog with your server FQDN in my case

Screenshot 4

Happy Blogging…!!!!!



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.