You can install WordPress very easily on a lean and per­for­mant NGINX server. If you’re already familiar with the CMS, you’ll know that in­stal­la­tion and con­fig­u­ra­tion can be done very quickly as long as you know how.

$1 Domain Names – Register yours today!
  • Simple reg­is­tra­tion
  • Premium TLDs at great prices
  • 24/7 personal con­sul­tant included
  • Free privacy pro­tec­tion for eligible domains

Why should you use WordPress with NGINX?

Many WordPress in­stal­la­tions run on Apache servers, but this doesn’t have to be the case. If you want to create your own WordPress site, you can also use NGINX as your web server instead. One of the benefits is that NGINX servers are generally con­sid­ered to be par­tic­u­lar­ly lean because they have low hardware re­quire­ments and hardly need any memory. At the same time, the web server can handle a lot of traffic. This makes NGINX a good Apache al­ter­na­tive for WordPress.

You aren’t sure whether you want to implement WordPress with NGINX? Our Nginx vs. Apache com­par­i­son article may help you decide between the two web server solutions.

What re­quire­ments must a server meet?

NGINX has low hardware re­quire­ments, which makes it par­tic­u­lar­ly suitable if you’re starting out with a small project since this is the kind of con­fig­u­ra­tion you need. If you use a flexible cloud server, you can add more resources over time. To publish a WordPress website, in addition to the web server, you also need your own domain and an SSL cer­tifi­cate to ensure a secure con­nec­tion.

You need the following basic re­quire­ments before in­stalling:

  • your own server
  • your own domain
  • a SSL cer­tifi­cate
Tip

Are you still looking for the right address for your WordPress website? At IONOS you can easily register a domain. You also get an SSL cer­tifi­cate included.

Once you have this in­fra­struc­ture (usually just a single contract is needed with your hosting provider), you can start the in­stal­la­tion. For this you need four different software com­po­nents:

  • NGINX: the actual web server
  • MySQL: a database that stores the content of your WordPress site, among other things
  • PHP: the scripting language that enables dynamic elements on your website
  • WordPress: the content man­age­ment system helps you define the look of your website and manage the content.

All the software com­po­nents you need for your own WordPress in­stal­la­tion are available for free. We explain how to install and properly configure each component.

Step by step guide to in­stalling WordPress with NGINX

In­stalling WordPress is done (according to the man­u­fac­tur­ers) in just 15 minutes. In addition, you also need to install NGINX, the database and PHP, but that also just takes a few minutes. We guide you through the in­stal­la­tion from in­stalling the web server to the first time you log into your WordPress site.

We use Ubuntu as the operating system in this tutorial. As always when it comes to in­stal­la­tions with Linux, you should ensure that the system up to date. Here are all the commands that need entering into the Ubuntu terminal:

sudo apt update
sudo apt upgrade
bash
Tip

The IONOS Setup Wizard can help make your work even easier. It takes just three steps to install WordPress. In the Hosting for WordPress plan from IONOS, all the pre­req­ui­sites are already in place, including high-per­for­mance in­fra­struc­ture.

Step 1: Install NGINX

First, we install NGINX on the system:

sudo apt install nginx
bash

The server is now installed and running. To test if every­thing worked, simply check the status:

sudo systemctl status nginx
bash

Exit the status display by pressing “Q” (like Quit) on your keyboard.

Step 2: Install MySQL

Next, you need to install a database. WordPress works with both MySQL and MariaDB. We decided to use the classic MySQL even though they both fared equally as well in the MariaB vs. MySQL com­par­i­son.

sudo apt install mysql-server
bash

Again, you can test if the in­stal­la­tion has worked by checking the status:

sudo systemctl status mysql
bash

The database is now installed, but it still needs to be con­fig­ured. To do this, first log in:

sudo mysql -u root -p
bash

Now you are in the MySQL area, which is where you can create a new database for your WordPress in­stal­la­tion:

CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
bash

And here is where you also create a new user including password for this database and assign the required rights. You’re free to choose the username and password:

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'
GRANT ALL PRIVILEGES ON WordPress.* TO 'user'@'localhost'
bash

Now leave MySQL again:

EXIT;
bash

Step 3: Install PHP

The last step before you install WordPress is to install the PHP scripting language. For this you need only one command, which then au­to­mat­i­cal­ly installs the latest PHP version:

sudo apt install php-fpm
bash

During the in­stal­la­tion process, you will also see which version is installed on your system. With this in­for­ma­tion, you can then verify that PHP is working correctly. In our case, version 8.2 was installed. If you already have a newer version, you must adjust the command ac­cord­ing­ly:

sudo systemctl status php8.2-fpm
bash

In order for PHP to work with the MySQL database, install the following extension:

sudo apt-get install php-mysql
bash
Note

With this command, you’ve installed the LEMP stack on your system. Just like with a LAMP server the letters L, M and P stand for Linux, MySQL (or MariaDB) and PHP. While LAMP uses an Apache server, LEMP uses the NGINX web server, pro­nounced like “EngineX”.

Step 4: Install WordPress

Now you can install WordPress. This can also be done directly via the Ubuntu terminal. First, however, create a folder so that you can install the content man­age­ment system af­ter­wards. It is rec­om­mend­ed to name the folder with the domain name. This way it makes it easier to keep several websites apart later on. So create the ap­pro­pri­ate folder and then change to this one:

sudo mkdir -p /var/www/html/example.com
cd /var/www/html/example.com
bash

Now it’s time to download the latest version from the official WordPress site and unzip the file:

wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
bash

Since the web server needs to make changes to the folder, you must give NGINX the ap­pro­pri­ate au­tho­riza­tion:

sudo chown -R nginx: /var/www/html/example.com/
bash

Step 5: Customize the WordPress con­fig­u­ra­tion file

You need to configure WordPress so that the CMS can work with your LEMP server. To do this, go to the WordPress directory and create the sample con­fig­u­ra­tion file wp-config.php. Then open the file:

cd /var/www/html/example.com
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php
bash
Note

You do not have to perform these steps from the command line. You can also use Ubuntu’s file manager and the pre-installed word processor to customize the con­fig­u­ra­tion file. Note, however, that you may then not have the necessary rights to make changes.

You still need to adjust the file, which you can do by changing the following lines in the document:

/** The name of the database for WordPress */
define( 'DB_NAME', 'Your database name' );
/** Database username */
define( 'DB_USER', 'The created username' );
/** Database password */
define( 'DB_PASSWORD', 'The password you set' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
bash

We set the required in­for­ma­tion for this in step 2. In our case the database is called “WordPress”, the username is simply “user” and the password we have simply set as “password”. When you have entered your data, you can save the document and close it again.

Step 6: Set NGINX

Now you need to configure NGINX for WordPress. To do this, create a new con­fig­u­ra­tion file in the NGINX file folder:

sudo nano /etc/nginx/conf.d/example.com.conf
bash

Enter the following code in the empty document:

server {
    listen 80;
    root /var/www/html/example.com;
    index  index.php index.html index.htm;
    server_name  wordpress.example.com;
    client_max_body_size 500M;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
}
bash

Make sure that you enter the correct path to your WordPress document at the beginning of the file. After that you can check the source code.

sudo nginx -t
bash

You should get an in­di­ca­tion that the syntax is ok and the text was suc­cess­ful. Finally, restart the server to make sure that all changes can take effect.

sudo systemctl restart nginx
bash

Step 7: Log into the WordPress dashboard

Now you have every­thing installed and you can start designing your WordPress website. To do this, launch a browser and access your domain. In this tutorial, we have set WordPress as a subdomain under “wordpress.example.com”. So you would need to visit the ap­pro­pri­ate subdomain, which is where you will be greeted with the first page of the setup wizard.

On the next page, enter the name of your website, create a first user and assign a password. You will need the last two pieces of in­for­ma­tion to log into the backend af­ter­wards. You will also be au­to­mat­i­cal­ly redi­rect­ed to this login screen once the setup is complete.

Now log in and start designing your website just how you want it. Your first tasks include choosing a WordPress theme, in­stalling the WordPress plugins and creating a WordPress menu.

Free Cloud Server Trial
En­ter­prise-grade virtual private servers
  • KVM based dev servers for de­vel­op­ers
  • Scalable to en­ter­prise cloud level
  • Pay-as-you-go, per-minute billing
Go to Main Menu