Installing and Setting up a WordPress on RHEL 7 / CentOS 7

Installing and Setting up a WordPress on RHEL 7 / CentOS 7

Basic Requirements

Step 1: Connect to the server using key or user/password

ssh -i ~/.ssh/demo.pem [email protected]

Step 2: update yum repo metadata.

sudo yum update -y

Step 3: Install wget

sudo yum install -y wget

Install LAMP (Linux, Apache, MySql [mariaDB] and PHP) stack

Step 1: Install, start, enable and check the status of Apache web server (httpd)

sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl status httpd
sudo systemctl enable httpd

Note: If you are looking for a secure, scalable managed WordPress management solution, take a look at Serverpilot WordPress management

Step 2: Install and start MariaDB (MySQL)

sudo yum install -y mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 3: Configure MariaDB. Enter appropriate values on each prompt.

sudo mysql_secure_installation

Step 4: Install php, php modules and restart httpd

sudo yum install -y php php-mysql php-gd
sudo systemctl restart httpd

Step 5: To test php installation, create simple PHP script. Open a test.php file using the following command.

sudo vi /var/www/html/demo.php

Step 6: Copy the following php script to the file and save it.

<?php phpinfo(); ?>

Step 7: Now, try accessing the demo script using the public IP followed by demo.php as shown below. If every configuration is correct, you will see a web page with all the installed php information.


Configure Database User and Password For WordPress

We should not use the root user and password for WordPress. It should be used only for administrative purposes. So let’s create a new database, user, and password for the WordPress website we are going to set up.

Step 1: Login to MariaDB (MySQL) with root credentials you created. It will open the MariaDB shell where you can run the scripts for managing databases and its users.

mysql -u root -p

Step 2: Create a database named wordpress. You can give your own database name.


Step 3: Now create a user named wordpress_admin for managing the wordpress database. You can choose your database username and password.

CREATE USER wordpress_admin@localhost IDENTIFIED BY 'password';

Step 4: Grant all database privileges to wordpress_admin on wordpress database.

GRANT ALL PRIVILEGES ON wordpress.* TO wordpress_admin@localhost IDENTIFIED BY 'password';

Step 5: Flush the privileges using the following command.


Step 6: Exit the database shell


Install and Configure WordPress

Now that we have all the components required for running WordPress, we will go ahead with the WordPress installation.

Step 1: Download latest WordPress


Step 2: Extract the tar file.

tar -xvf latest.tar.gz

Step 3: Copy wordpress folder content to /var/www/html folder

cp -vR  wordpress/* /var/www/html/

Step 4: Change the owner of /var/www/html to apache user. Because the WordPress files will be manipulated by httpd apache user.

sudo chown -R apache:apache /var/www/html/*

Configuring WordPress

Step 1: cd in to /var/www/html folder


Step 2: Copy wp-config-sample.php to wp-config.php file.

cp wp-config-sample.php wp-config.php

Step 3: Open wp-config.php file and add the database details in the following parameters.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpress_admin');

/** MySQL database password */
define('DB_PASSWORD', 'password');

That’s it! If you browse to the IP you will be able to access the WordPress website

Also read,

  1. How to Setup Free SSL (https) for WordPress Website using Cloudflare
  2. How to SetUp High-Performance WordPress on Cloud/VPS
Installing and Setting up a WordPress on RHEL 7 / CentOS 7

Other Interesting Blogs

Leave a Comment

Share via
Copy link
Powered by Social Snap