How To Install Wordpress on Debian 9 with LEMP

WordPress is an excellent platform for running your blog. Debian 9 with LEMP is an excellent backend to run WordPress on, combining the reliability of the LEMP stack with WordPress’s feature set.

While not as common as the LAMP stack, LEMP is often a superior backend for high volume WordPress sites due to the Nginx web server’s performance in high load situations.

Install LEMP

  1. Update the System and Install CURL

$ sudo apt-get update && sudo apt-getinstall$ sudo apt-get install curl
  1. Install NGINX

$ sudo apt install nginx
  1. Install MySQL

$ sudo apt install mysql-server
$ sudo mysql_secure_installation
  1. Install PHP Extensions

$ sudo apt install php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip

$ sudo systemctl restart php-fpm

Configure Nginx to use the PHP Processor

  1. Create a Root Directory For Your Domain

$ sudo mkdir /var/www/
  1. Create a Configuration File

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

Add the following to the file:

server {
    listen [::]:80;

    root /var/www/yourdomain;
    index index.php index.html index.htm;

    server_name yourdomain;

    location / {
        #try_files $uri $uri/ =404;
        try_files$uri$uri/ /index.php$is_args$args;


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

    location = /favicon.ico { log_not_foundoff; access_logoff; }
    location = /robots.txt { log_not_foundoff; access_logoff; allow all; }
    location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;

  1. Symlink the Config Files From Nginx’s sites-available Directory

$ sudo ln -s /etc/nginx/sites-available/yourdomain.conf /etc/nginx/sites-enabled/
  1. Restart Nginx

$ sudo systemctl reload nginx

Configure MySQL

  1. Add a MySQL User

$ sudo mysql -u root -p
>  CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  1. Set the User Rights

> GRANT ALL ON wordpress.* TO 'databaseuser'@'localhost' IDENTIFIED BY 'password';

>  Flush Privileges;

> Exit;

Download and Configure WordPress

  1. Download the File to a Writable Directory

$ cd /tmp
$ curl -LO
  1. Extract the File

$ tar xzvf latest.tar.gz
  1. Create a Config File From the Sample WordPress Config File

$ cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
  1. Copy the WordPress Files Over to the Web Document Root Directory

$ sudo cp -a /tmp/wordpress/. /var/www/
  1. Assign Ownership of the Files

$ sudo chown -R www-data:www-data /var/www/
  1. Generate Secret Key Values

$ curl -s
  1. Copy the Secret Keys into the WordPress Configuration File

$ sudo nano /var/www/yourdomain/wp-config.php

You will find a section in the file that looks like this:

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

Replace this with the output from the command run in step 6.

  1. Update the Database Information in the WordPress Configuration File

In the WordPress Configuration File find the lines

define('DB_NAME', 'wordpressdatabasename');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'password');

Update these lines with the values used when you created your database. Add the line below as well and then save and close the file.

define('FS_METHOD', 'direct');


Finish the Install from the UI

  1. Select the Language

    How To Install WordPress on Debian 9 with LEMP

  2. Provide Some Basic Site Information and Setup the Admin Account

    How To Install WordPress on Debian 9 with LEMP

  3. You Will See a Confirmation Screen

How To Install WordPress on Debian 9 with LEMP

  1. Login and You Can Begin Setting Up Your Site!

    How To Install WordPress on Debian 9 with LEMP

Now that you’ve logged in take a few minutes to look over the navigation menu on the left hand side. You can access all of the major features of WordPress including theme selection, plugins, and user setup from here. WordPress is a powerful CRM and now that you have it up and running, you should be able to get your site up and running in no time at all.

How To Install WordPress on Debian 9 with LEMP

Check out these top 3 WordPress hosting services:

Was this article helpful?