NEW VPS PLANS

Experience Ultra-high Performance of NVMe Storage on New UK VPS Plans.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How to install WordPress on CentOS 7 wit...

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

NetShop ISP

NetShop ISP · Blog Author

Aug 04, 2020 · Archive

Updated on March 03, 2021


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.

Prerequisites

  • You have a domain name pointed to your server public IP address. In this tutorial we will use example.com.
  • 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
[mariadb]
 name = MariaDB
 baseurl = http://yum.mariadb.org/10.3/centos7-amd64
 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
 gpgcheck=1
  • 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';
  • FLUSH PRIVILEGES;
  • 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 http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  • 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
listen.group = 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/example.com

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

  • cd /tmp
  • wget https://wordpress.org/latest.tar.gz

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/example.com/

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/example.com

Nginx Configuration Instructions

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

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

Paste the following block and then save the file:

# Redirect HTTP -> HTTPS
#server {
# listen 80;
# server_name www.example.com example.com;

# include snippets/letsencrypt.conf;
# return 301 https://example.com$request_uri;
#}

# Redirect WWW -> NON WWW
#server {
# listen 443 ssl http2;
# server_name www.example.com;

# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
# include snippets/ssl.conf;

# return 301 https://example.com$request_uri;
#}

server {
# listen 443 ssl http2;
listen 80;
server_name example.com;

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

# SSL parameters
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
# include snippets/ssl.conf;
# include snippets/letsencrypt.conf;

# log files
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

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

}

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. example.com) to continue with the Wizard-style installation of WordPress.

Achieve More & Do Less with Managed Server Hosting

NetShop ISP offered Fully Managed hosting for your VPS and Dedicated Server so that you can truly focus on managing your business, not your server.

Simply check the Managed Server option during your checkout and we will handle the rest!

For more information don’t hesitate to contact our Hosting specialists today!

Press Releases
72

Free VPS Trial

No Credit Card Required.

Recent Posts

How To Migrate from MongoDB Atlas to self-hosted Ubuntu 22.04 Server

How To Migrate from MongoDB Atlas to self-hosted Ubuntu 22.04 Server

15 April, 2024

How NetShop ISP Improves Trading Infrastructure Resilience through Equinix LD7 Data Center Hosting

How NetShop ISP Improves Trading Infrastructure Resilience through Equinix LD7 Data Center Hosting

21 March, 2024

Introducing New Cutting-Edge VPS Plans: OKTAPLUS, HYPER, and TITAN Enhanced with NVMe Technology

Introducing New Cutting-Edge VPS Plans: OKTAPLUS, HYPER, and TITAN Enhanced with NVMe Technology

12 March, 2024

How To Install Let’s Encrypt SSL on Ubuntu Server 22.04 for Apache or Nginx

How To Install Let’s Encrypt SSL on Ubuntu Server 22.04 for Apache or Nginx

04 March, 2024

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

23 February, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer