How to Install WordPress With LEMP Stack - (Part1).

In this post, we will be talking How to install WordPress with LEMP stack on CentOS 7 VPS (Part1).

WordPress is one of the most popular and widely used content management systems, blogging platforms in the world. It is popularly used as a Blog, Portfolio Website, etc.

In this tutorial, you are going to learn how to install WordPress with LEMP(Linux,Nginx,MySQL,and PHP) on CentOS 7 Linux VPS.


Table of Content

  1. Prerequisites
  2. Install MySQL 8.0
  3. Configure Database in MySQL
  4. Install & Configure PHP 7.2
  5. Install Nginx
  6. Configure Firewall
  7. Configure Nginx File
  8. Install WordPress File
  9. Test WordPress

1. Prerequisites


Before you start the installation of WordPress with (LEMP) stack on Centos 7 VPS, you must have one Centos 7 VPS with root privileges on it or you can use sudo for non-root user.

You should also run basis command on the server to check the following things-:

# df -h (To check the disk space on the system.)

 

# cat /etc/os-release (To verify the version of the VPS.)

 

# yum -y update (To update all the packages of the VPS)

2. Install MySQL 8.0

WordPress uses a MySQL database for storage, MySQL is used in the stack for storing user details in the database.

For installing MySQL on Centos 7 first you need to enable MySQL repository and then you can install MySQL.

# yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

The command used for installing MySQL in CentOS 7 VPS is as follows:

# yum install mysql-server -y

Then check the MySQL version by typing the following command:

# mysql -V(‘V’ is in uppercase)

After the installation is completed MySQL will start automatically and you can check it’s status by typing:

# systemctl status mysqld

If MySQL does not start automatically you can write the following command:

# systemctl start mysqld

Before going for the next step you should generate a temporary password to access MySQL root user with the following command:

# grep ‘temporary password’ /var/log/mysqld.log
Now configure the MySQL secure installation to improve the security by typing the following commands.
#
mysql_secure_installation

Log in with the temporary password and assign a new password, after that in this configuration it asks several questions you can give Y or N according to your requirement.

Change the password for root? N

Remove anonymous users? Y

Disallow root login remotely? Y

Remove test database and access to it? Y

Reload privilege tables now? Y

 

3. Configure Database in MySQL

Now create a database for WordPress in MySQL for that first login with MySQL server by using the following command:

# mysql -u root -p

And give its password, after that create a database in it with the command:
mysql> CREATE DATABASE WordPress;

You can also check that database is created or not with the command:

mysql> SHOW DATABASES;

Now create a user and assign him a password by using the command:

mysql> CREATE USER ‘wordpress’@’localhost’ IDENTIFIED

BY ‘Password’;

After that grant all privileges to the user-created under that database with the command:

mysql> GRANT ALL ON WordPress.* TO ‘wordpress’@’localhost’;

Then flush all privileges on MySQL server with the command:

mysql> FLUSH PRIVILEGES;

Now exit from the MySQL server you can use commands:

mysql> exit;

mysql> \q;

Note-: In MySQL you must end each command with a semicolon(;).

4. Install & Configure PHP 7.2

PHP is used by WordPress to do various functions done by PHP like calling plugin, calling theme, validating user permissions, checking the option, grab from the database, etc.

In this Blog we are using PHP 7.2 version and install it with epel-release with remi repository.

Firstly, install yum-utils packages using the following command:

# yum -y install yum-utils

After that, install epel-release package by using the command:

# yum -y install epel-release

Then import remi repository from the command:

# yum -y install http://rpms.remirepo.net/enterprise/

remi-release-7.rpm

Enable the remi repository by typing:
# yum-config-manager –enable remi-php72

After that install PHP and all required modules by using command:

# yum -y install php-fpm php-mysql php-mbstring php-xml php-gd php-cli php-json php-opcache php-curl
Now after the installation completed you can check the PHP version with the command:
# php -v (‘v’ is in smallcase)

 

To be Continued………

Learn how to scale, manage, and optimize your applications with a SLB. Read our solution brief "Get More from Your Enterprise Network".

DOWNLOAD SOLUTION BRIEF

Get started with CloudMinister Today