page-banner-shape-1
page-banner-shape-2

How to install WordPress with LEMP stack on CentOS 7 VPS (Part1).

  • Tanuj Chugh
  • August 10, 2020

How to install WordPress with LEMP stack on CentOS 7 VPS (Part1).

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 sudo privileges

Start by updating your system packages to their latest versions:

bash
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:

bash
sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm

1.2 Install MySQL Server:

bash
sudo yum install -y mysql-community-server

1.3 Start and Enable MySQL:

bash
sudo systemctl start mysqld
sudo systemctl enable mysqld

1.4 Secure Your MySQL Installation:
A temporary password is generated during installation. Retrieve it with:

bash
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.

bash
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:

bash
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.

sql
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 of root significantly 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:

bash
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:

bash
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:

bash
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.

bash
sudo systemctl start php-fpm
sudo systemctl enable php-fpm

3.5 Verify Installation:
Check that PHP 7.2 was installed correctly:

bash
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:

  1. Installing and configuring Nginx as our high-performance web server.

  2. Creating an Nginx Server Block to host our WordPress site.

  3. Downloading and setting up WordPress files with correct permissions.

  4. 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………

Tanuj Chugh

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.

https://cloudminister.com/
Call Now Button