FREE Hosting for 1 Month Claim Now
FREE Hosting for 1 Month

Claim Now

How to install WordPress on CentOS 7 with MariaDB 10, Nginx and PHP-FPM 7

How to install WordPress on CentOS 7 with MariaDB 10, Nginx and PHP-FPM 7

WordPress is one of the most popular open source Content Management systems, powering almost one out of three (1/3) websites on the Internet today. It is based on PHP and MySQL and packs a ton of features that can be extended with free and premium plugins and themes. WordPress is the simplest way to create your online store, website, or blog.

This tutorial will help you to install WordPress on CentOS 7 with Nginx as a web server, MariaDB 10.3 and PHP-FPM 7.3. It is an easy and straight-forward process and you can have your website up and running in less than 10 minutes.


  • You have a domain name pointed to your server public IP address. In this tutorial we will use
  • You have ssh access on your dedicated / vps server and logged in as a user with sudo privileges.

Before starting make sure you update and upgrade all OS libraries and packages:

  • sudo yum update
  • sudo yum upgrade

Install Maria DB 10.3

Adding the MariaDB YUM repository

  • vi /etc/yum.repos.d/MariaDB.repo
 name = MariaDB
 baseurl =
  • yum update -y

Install MariaDB 10.3 on CentOS 7

  • yum install MariaDB-server MariaDB-client

Start & Enable MariaDB on CentOS 7

Once the installation is done, you can start and enable MariaDB to run on system boot by executing the commands below:

  • systemctl start mariadb
  • systemctl enable mariadb

Set MariaDB Root Password

  • mysql_secure_installation

The first prompt would be to set the root password. however, if you have set it above, just enter the password and proceed.

... In order to log into MariaDB to secure it, we'll need the current password for the root user.  If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none):  OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n

Next, remove the database anonymous user.

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y  ... Success!

Now, disable remote root login

Normally, root should only be allowed to connect from 'localhost'.  This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n]   ... Success!

Next, remove test databases

By default, MariaDB comes with a database named 'test' that anyone can access.  This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y  - Dropping test database...  ... Success!  - Removing privileges on test database...  ... Success!

Finally, reload the privileges tables to effect the changes.

Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y      ... Success!

Now restart mariadb:

  • systemctl restart mariadb

You have successfully installed MariaDB 10.3 on CentOS 7 Server. Now lets proceed with the next steps.

Create WordPress Database and WordPress DB User

Login to the MySQL shell by executing the following command:

  • mysql -u root -p

Now create the database, user and grant user to database privileges by executing the following commands. We will use ‘wpdb’ as the database name in our example and ‘wpuser’ for the database username.

  • CREATE DATABASE wpdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
  • GRANT ALL ON wpdb.* TO ‘wpuser’@’localhost’ IDENTIFIED BY ‘enter-strong-password-here’;
  • EXIT;

Install PHP 7.3

To install PHP and all required PHP extensions run the following commands:

  • yum install epel-release yum-utils
  • yum install
  • yum-config-manager –enable remi-php73
  • yum install php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl

PHP FPM has now been installed and we will be using Nginx as a web server. By default PHP FPM will run as user apache on port 9000. We’ll change the user to nginx and switch from TCP socket to Unix socket. To do so open the /etc/php-fpm.d/www.conf file edit the lines mentioned below:

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx = nginx

Then, make sure the /var/lib/php directory has the correct ownership using the following chown command:

  • sudo chown -R root:nginx /var/lib/php

Start & Enable PHP-FPM on CentOS 7

  • systemctl enable php-fpm
  • systemctl start php-fpm

Now, the WordPress Part…

Before downloading the WordPress archive, you should create a directory in which we will place the WordPress files:

  • sudo mkdir -p /var/www/html/

The next step is to download the latest version of WordPress from the WordPress download page using the following wget command :

  • cd /tmp
  • wget

Once the wordpress archive file downloading completes, decompress the downloaded file and move the files into the directory you have created from the previous step:

  • tar xf latest.tar.gz
  • sudo mv /tmp/wordpress/* /var/www/html/

Set the correct permissions so that the web server can have full access to the site’s files and directories:

  • sudo chown -R nginx: /var/www/html/

Nginx Configuration Instructions

Create a new file with name “” under /etc/nginx/conf.d as follows:

  • sudo nano /etc/nginx/conf.d/

Paste the following block and then save the file:

# Redirect HTTP -> HTTPS
#server {
#    listen 80;
#    server_name;

#    include snippets/letsencrypt.conf;
#    return 301$request_uri;

# Redirect WWW -> NON WWW
#server {
#    listen 443 ssl http2;
#    server_name;

#    ssl_certificate /etc/letsencrypt/live/;
#    ssl_certificate_key /etc/letsencrypt/live/;
#    ssl_trusted_certificate /etc/letsencrypt/live/;
#    include snippets/ssl.conf;

#    return 301$request_uri;

server {
#    listen 443 ssl http2;
     listen 80;

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

    # SSL parameters
#    ssl_certificate /etc/letsencrypt/live/;
#    ssl_certificate_key /etc/letsencrypt/live/;
#    ssl_trusted_certificate /etc/letsencrypt/live/;
#    include snippets/ssl.conf;
#    include snippets/letsencrypt.conf;

    # log files
    access_log /var/log/nginx/;
    error_log /var/log/nginx/;

    location = {
        log_not_found off;
        access_log off;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;

    location / {
        try_files $uri $uri/ /index.php?$args;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;


After you save& close the above file, execute the following command to verify the configuration of nginx:

  • sudo nginx -t

If no errors are shown in the output of the above command, proceed with restarting nginx for the new configuration to be effective:

  • sudo systemctl restart nginx

You are now Done with the Server-side Configuration

Now open your browser and type the domain name you configured in the nginx file (e.g. to continue with the Wizard-style installation of WordPress.

Related Articles

Recent Posts

Why Host Your Server in Amsterdam, The Netherlands
Work@Home Bundle Featured at SBC News
3 Reasons Why Host a Server in Singapore
Work@Home - Enable Remote Collaboration
NetShop ISP Announces World-class Forex VPS Plans

© Copyright 2004-2020 S.S. NETSHOP INTERNET SERVICES LTD trading as “NetShop ISP”. All rights reserved.

If you have found a spelling error, please notify us by selecting the text and pressing Ctrl+Enter.

Forgot Password? Click here

Not a Client Yet?

Spelling error report

The following text will be sent to our editors: