How To Install WordPress On CentOS 7

This guide will help you install WordPress on Linux CantOS, First Lets update your system :

sudo yum update -y

Then install all Prerequisites like LAMP Packages :

sudo yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt php-xmlrpc unzip wget -y

Once the packages finished installation, Make them enabled and start on boot :

sudo systemctl start httpd
sudo systemctl start mariadb
sudo systemctl enable httpd
sudo systemctl enable mariadb

Then we will need to configure the database :

sudo mysql_secure_installation

You can answare the wizrad as shown below

Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Then we will need to configure the MariaDB, the user@localhost and the password will be used for the connection to the database on the WordPress configuration file (you can change this):

mysql -u root -p
MariaDB [(none)]>CREATE DATABASE wordpress;
MariaDB [(none)]>GRANT ALL PRIVILEGES on wordpress.* to 'user'@'localhost' identified by 'password';
MariaDB [(none)]>exit

Now we are ready to install WordPress itself, lets get the latest version for WordPress :


You will need to extract it to the current directory :

tar -xzvf latest.tar.gz

The copy it to Apache root directory, in our case  :

sudo cp -avr wordpress/* /var/www/html/

You also want to prepare directory to upload files to the system :

sudo mkdir /var/www/html/wp-content/uploads

now we need to give permission and owner to the WordPress folders:

sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/

If you are using SElinux you also need to allow access :

 chcon -R --reference=/var/www /var/www/html/

Now we need to configure the WordPress to be able to use the Database,we will use the sample file as template to start with :

cd /var/www/html/
sudo mv wp-config-sample.php wp-config.php
sudo nano wp-config.php

Change the value according to the date you enter before, and save the file :

define('DB_NAME', 'wordpress');
define('DB_USER', 'user');
define('DB_PASSWORD', 'password');

Now You will need to allow access through the firewall :

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

That’s It !!!¬† now open browser and start the wordpress configuration at :


From here you will need to follow the wizard through to the end

Good Luck




Leave a Reply

Your email address will not be published.