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


  • 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.
  • 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
... 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
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!
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!
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!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y      ... Success!
  • systemctl restart mariadb

Create Wordpress Database and Wordpress DB User

Login to the MySQL shell by executing the following command:

  • mysql -u root -p
  • 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:

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx = nginx
  • 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/
  • tar xf latest.tar.gz
  • sudo mv /tmp/wordpress/* /var/www/html/
  • 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/
# 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 = /favicon.ico {
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;

  • sudo nginx -t
  • 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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store