
WordPress powers over 40% of all websites on the internet. While it’s traditionally paired with Apache (LAMP), running it on Nginx (LEMP) offers superior performance and efficiency, especially under high traffic.
This tutorial is Part 1 of a two-part series. Here, you will learn how to prepare your CentOS 7 server by installing and configuring the core backend components: MySQL 8.0 and PHP 7.2.
Prerequisites
Before you begin, ensure you have:
-
A CentOS 7 VPS
-
SSH access as a user with
sudoprivileges
Start by updating your system packages to their latest versions:
sudo yum -y update
Step 1: Install MySQL 8.0
WordPress requires a database to store all your content, posts, and users. We’ll use MySQL 8.0.
1.1 Add the MySQL Repository:
sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm
1.2 Install MySQL Server:
sudo yum install -y mysql-community-server
1.3 Start and Enable MySQL:
sudo systemctl start mysqld sudo systemctl enable mysqld
1.4 Secure Your MySQL Installation:
A temporary password is generated during installation. Retrieve it with:
sudo grep 'temporary password' /var/log/mysqld.log
Then, run the security script. It will guide you through setting a new root password and hardening your database security.
sudo mysql_secure_installation
Follow the prompts. It is highly recommended to:
-
(Y) Change the root password? (Use the temp password first, then set a new strong one)
-
(Y) Remove anonymous users?
-
(Y) Disallow root login remotely?
-
(Y) Remove test database and access to it?
-
(Y) Reload privilege tables now?
Pro Tip: MySQL 8.0 enforces a strong password policy. Your new password must be strong (12+ characters, mix of upper/lower case, numbers, and symbols). Save this password in a secure place.
Step 2: Create a Database for WordPress
For security best practices, never use the MySQL root user for applications. Instead, create a dedicated database and user for WordPress.
2.1 Log into MySQL:
mysql -u root -p
Enter the root password you just set.
2.2 Create the Database and User:
Run these commands within the MySQL shell. Replace 'your_strong_password' with a very secure password of your own.
CREATE DATABASE wordpress_db; CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_strong_password'; GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
Pro Tip: Using a dedicated user (
wordpress_user) instead ofrootsignificantly improves your site’s security. If WordPress is compromised, the damage is limited to a single database.
Step 3: Install & Configure PHP 7.2
CentOS 7 ships with an outdated version of PHP. We will use the Remi repository to install PHP 7.2, which is fast, stable, and fully supported by modern WordPress.
3.1 Add the Required Repositories:
sudo yum install -y epel-release yum-utils sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
3.2 Enable the PHP 7.2 Repository:
sudo yum-config-manager --enable remi-php72
3.3 Install PHP and Necessary Extensions:
WordPress and its plugins require specific PHP modules. Install them all at once:
sudo yum install -y php-fpm php-mysqlnd php-json php-opcache php-mbstring php-xml php-gd php-curl
3.4 Start and Enable PHP-FPM:
PHP-FPM (FastCGI Process Manager) is the service that will process PHP code.
sudo systemctl start php-fpm sudo systemctl enable php-fpm
3.5 Verify Installation:
Check that PHP 7.2 was installed correctly:
php -v
Pro Tip: This is just the base PHP setup. In Part 2, we will fine-tune the PHP configuration (
/etc/php.ini) for optimal WordPress performance, adjusting parameters like memory limit and upload size.
What’s Next? (Teaser for Part 2)
You have now successfully installed and configured the database and application layers of the LEMP stack!
In Part 2 of this tutorial, we will cover:
-
Installing and configuring Nginx as our high-performance web server.
-
Creating an Nginx Server Block to host our WordPress site.
-
Downloading and setting up WordPress files with correct permissions.
-
Running the famous 5-minute WordPress install via the web browser.
Your server is now ready for the final steps. Stay tuned for Part 2 to complete your WordPress installation!
Tired of Manual Server Configuration?
Setting up a server from scratch is complex and time-consuming. Let us handle the infrastructure so you can focus on creating content and growing your website.
Our Optimized WordPress Hosting includes:
-
LEMP Stack Pre-Installed & Fine-Tuned for maximum speed.
-
1-Click WordPress Installation – no command line needed.
-
Free SSL Certificates & Daily Backups for peace of mind.
-
24/7 Expert Support from server professionals.
To be Continued………

He is the CEO and Founder with over a decade of experience in cloud infrastructure, DevOps, and server optimization. With a strong vision and hands-on leadership approach, he has built scalable, secure, and high-performance cloud solutions trusted by businesses across industries.



