AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Install WordPress on Nginx – IONOS

PARTAGEZ

You can easily install WordPress on a lightweight and high performance Nginx server. As usual with the CMS, installation and configuration is done very quickly, if you know how.

Cheap internet domain

Much more than just a domain!

Personalize your online presence with a relevant domain name.

E-mail
SSL certificate
24/7 Support

Why use WordPress on Nginx?

Many WordPress installations run on Apache servers. However, this is not an absolute necessity. If you want to create your own WordPress site, you can also use Nginx as a web server. Indeed, it has several advantages. Nginx is considered particularly lightweight: it only requires little hardware and memory. Moreover, it is capable of handling heavy traffic. That’s why it’s a good alternative to Apache for WordPress.

Are you still hesitating to build WordPress with Nginx? In our article Nginx vs. Apache, we compare the two web server solutions.

What are the server requirements?

Nginx requires very little hardware. If you want to start with a small project, it is therefore worth opting for a configuration with few resources. By using a flexible cloud server, you can add additional resources over time. To publish a WordPress website, in addition to the web server, you need your own domain and an SSL certificate for a secure connection.

So here are the basic elements you need before installation:

  • a personal server
  • a domain
  • an SSL certificate

Advice

Are you still looking for the right address for your WordPress website? At IONOS, you can easily register a domain. The SSL certificate is already included there.

Once this infrastructure is in place (everything is usually included in a contract with a hosting provider), you can begin the installation. For this, you need four different software components:

  • Nginx: the webserver
  • MySQL: a database that stores, among other things, the content of your WordPress site
  • PHP: the scripting language that allows you to place dynamic elements on your website
  • WordPress: the content management system allows you to define the appearance of your website and manage its content.

All the software components you need for your own WordPress installation are available for free. We explain how to install and configure them correctly.

Install WordPress on Nginx: step by step

Installing WordPress takes just 15 minutes. You also need to install Nginx, the database and PHP, but all this only takes a few minutes. We walk you through the process, from installing the web server to connecting to your WordPress site for the first time.

In this guide, we use Ubuntu as the operating system. As always during installations under Linux, it is advisable to update the system. All commands must be entered in the Ubuntu terminal:

sudo apt update
sudo apt upgrade

Advice

To make it easier for you, the IONOS installation wizard is there to help you: you can install WordPress in just three steps. With WordPress hosting from IONOS, you already benefit from all the prerequisites, including a high-performance infrastructure.

Step 1: Install Nginx

Start by installing Nginx on the system:

The server is now installed and running. To see if everything went well, you can view the status:

sudo systemctl status nginx

You quit the window by pressing “Q” (like Quit) on your keyboard.

Step 2: Install MySQL

Next, you need to install a database. Since WordPress works with both MySQL and MariaDB, we’re going with MySQL, even though there isn’t really a winner in the MariaB vs MySQL comparison.

sudo apt install mysql-server

Here again, you can test the proper functioning of the installation by checking its status:

sudo systemctl status mysql

The database is now installed, but still needs to be configured. To do this, start by logging in:

You are now in the MySQL area. Here you can create a new database for your WordPress installation:

CREATE DATABASE WordPress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

You can also create a new user there with a password for this database and assign him the necessary rights. Username and password can be chosen freely:

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

Now all you have to do is quit MySQL:

Step 3: Install PHP

The last preparatory step before installing WordPress is to install the PHP scripting language. To do this, you just need to use a command that automatically installs the latest version of PHP:

During the installation process, you will also see which version is installed on your system. With this information, you can then check if PHP is working properly. In our case, version 8.2 was installed. If you have a more recent version, remember to adapt the command accordingly:

sudo systemctl status php8.2-fpm

Finally, install the corresponding extension so that PHP can also work with the MySQL database:

sudo apt-get install php-mysql

Note

The LEMP stack is now installed on your system. Just like for a LAMP server, the letters L, M and P stand for Linux, MySQL (or MariaDB) and PHP. The big difference is the use of an Apache server for LAMP and an Nginx web server (whose name is pronounced like “EngineX”) for LEMP.

Step 4: Install WordPress

You can now install WordPress. This step is also done directly via the Ubuntu terminal. Start by creating the folder in which you will then install the content management system. It is recommended to name the folder with the domain name. This will allow you to distinguish between your different websites later. Just create the corresponding folder and go there:

sudo mkdir -p /var/www/html/exemple.fr
cd /var/www/html/exemple.fr

Now 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

Since the web server needs to make changes to the folder, give Nginx the corresponding permission:

sudo chown -R nginx: /var/www/html/exemple.fr/

Step 5: Customize the WordPress Configuration File

You now need to configure WordPress so that the CMS can work with your LEMP server. To do this, navigate to the WordPress directory and transform the example configuration file into wp-config.php. Then open the file:

cd /var/www/html/exemple.fr
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Note

You do not need to perform these steps through the command line. You can also use Ubuntu’s file manager and pre-installed word processor to edit the configuration file. But be aware that in this case, you may not have the necessary rights to make changes.

Now you need to adapt the file. Edit the following lines in the document:

/** The name of the database for WordPress */
define( 'DB_NAME', 'Le nom de votre base de données' );

/** Database username */
define( 'DB_USER', 'Le nom d'utilisateur créé' );

/** Database password */
define( 'DB_PASSWORD', 'Le mot de passe que vous avez défini' );

/** Database hostname */
define( 'DB_HOST', 'hôte local' );

The necessary information was defined in step 2. In our case, the database is called “WordPress”, the username is simply “user” and the password is “password”. Once you have entered your data, you can save the document and close it.

Step 6: Configure Nginx

Now you need to configure Nginx for WordPress. To do this, create a new configuration file in the Nginx files folder:

sudo nano /etc/nginx/conf.d/exemple.fr.conf

Enter the following lines in the empty document:

server {
    listen 80;
    root /var/www/html/exemple.fr;
    index  index.php index.html index.htm;
    server_name  wordpress.exemple.fr;

    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;
    }
}

Be careful to indicate at the beginning of the file the correct path to your WordPress document. You can then have the Nginx source code checked.

You should see a message that the syntax is correct and the text is successful. Finally, restart the server for all changes to take effect.

sudo systemctl restart nginx

Step 7: Login to the WordPress Dashboard

Now that everything is installed, you can start creating your WordPress site. To do this, launch a browser and navigate to your domain. In this tutorial, we have defined WordPress as a subdomain under “wordpress.example.fr”. You must therefore call the corresponding subdomain. You will then be greeted by the first page of the installation wizard.

On the next page, enter your website name, create a first user, and assign a password. These last two pieces of information will be necessary for you connect to backend. You will be automatically redirected to this login screen as soon as the setup is complete.

Log in now and start setting up your website the way you want. Your first task will be to choose a WordPress theme, install the best WordPress plugins and create a WordPress menu.

Try the cloud server with IONOS for free

Test our cloud server for free – Test your cloud server at IONOS for 30 days!

REST-API
Unlimited traffic
VMware Virtualization

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact

Suivez-nous:

© 2024 AMZ DIGICOM All Rights Reserved