Installing WordPress on CentOS 7 using PHP 7, MySQL 5.7, nginx, PHP-FPM

In this guide we will provision a basic WordPress installation on a clean install of CentOS 7 running PHP 7 and MySQL 5.7, and served via nginx and PHP-FPM.

The process could very easily be automated with one of the many provisioning tools available, but sometimes a more hands-on approach can help you understand better how the pieces fit together, and it’s often easier to debug when something doesn’t go to plan.

On a fresh installation, you’re probably already logged in as root but if not then sudo su - now and make sure everything is up-to-date first by running yum -y update.

Set up some reusable variables to simplify the installation process:

IMPORTANT: MySQL password policy

By default, MySQL 5.7 has a strict password policy enabled – set to MEDIUM – which means you need to use passwords that are at least 8 characters long and contain at least 1 numeric character, 1 lowercase and uppercase character, and 1 special (nonalphanumeric) character.

PHP 7

MySQL 5.7

Change the password for the MySQL root user:

nginx

Configure the firewall to allow HTTP(S) traffic through:

Configure PHP-FPM and nginx to communicate over a unix socket instead of TCP:

WordPress

Create the database

Create a new database user

Create a new server in nginx

Note that this creates two new config files in /etc/nginx/conf.d/. This setup assumes you want to redirect requests for www.example.com to example.com. If you’d prefer the other way round you need to switch the filenames around then update the server_name directive in both files and prepend www. to the redirect URL in what is now example.com.conf.

Download and extract WordPress into place

All done

You should now be able to browse to http://example.com and start configuring your new WordPress installation using the same database settings you defined at the start of the guide.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *