How To Install Wordpress on Debian 9 with LEMP

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/yourdomain.com
  1. Create a Configuration File

$ sudo nano /etc/nginx/sites-available/yourdomain.com

Add the following to the file:

server {
    listen80;
    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;
        log_not_foundoff;
    }

}
  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 https://wordpress.org/latest.tar.gz
  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/yourdomain.com
  1. Assign Ownership of the Files

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

$ curl -s https://api.wordpress.org/secret-key/1.1/salt/
  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:

A2 Hosting
AU$4.50 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
AU$1.50 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
HostArmada
AU$3.74 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0

How to Configure WordPress Page Caching

A savvy website owner understand how important it is to have a website with a qu
4 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Secure Your WordPress Website

Millions of websites get hacked every year and many people consider WordPres
5 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Create a WordPress Child Theme

Customizing your WordPress theme but want to be extremely safe? Don’t worry. W
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Fix File and Folder Permissions Errors in WordPress

It's so frustrating when you receive an error while updating your website. File
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top