WordPress is a free & open source website/blogging tool, it's based on MySQL & php. Currently it powers around 27% websites available on internet. Its ease of use makes it a perfect choice for beginners as well as expert bloggers. WordPress supports a large number of plugins & themes, which enhances its usability & customization. Also there is huge community of dedicated wordpress users out there that are always willing & able to provide support as & when needed.

In this tutorial, we are going to install wordpress on Centos 7 but same tutorial can be used with earlier versions of RHEL/Centos also.

Pre-requisites

1- We will need a LAMP server to install wordpress on. Kindly refer to our article on creating a LAMP server to create one. Once the LAMP server is ready, we can move on with this tutorial.

2- Apart from the php modules installed during the installation of LAMP server, we also need php-gd installed on our system. We can install by using following command,

$ yum install php-gd

Restart the httpd service to implement the changes.

$ systemctl restart httpd

 

Step 1- Configuring MySQL

We need to create a database for our wordpress website. To create the database, login to the MySQL server,

$ mysql -u root -p

and create a database table for wordpress,

$ CREATE DATABASE wordpressdb;

Once the database has been created, we will assign a user with complete access to the created database i.e. 'wordpressdb',

$ GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wppasswd';

To make Mysql aware of the recent privilege changes, we will run the following command,

FLUSH PRIVILEGES;

The changes on Mysql are complete, we can now exit the Mysql.

 

Step 2 – Installing WordPress

We can now install wordpress on our system, the latest of the wordpress version is always available on the same link. To install download wordpress, run

$ wget http://wordpress.org/latest.tar.gz

then, extract the package,

$ tar -xvf latest.tar.gz

After the package has been extracted, there will be an extracted folder called 'wordpress'. We need to move this folder in /var/www/html,

$ mv -vf wordpress /var/www/html

We will now assign the proper permissions i.e. grant ownership of all content inside /var/www/html to apache user,

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

 

Step 3 – Configuring wordpress

We will now edit the wordpress configuration file i.e. wp-config.php but by default there is no file by that name under /var/www/html/wordpress. But we can use a sample configuration file that is already inside the wordpress folder, by renaming it to wp-config.php,

$ cd /var/www/html

$ mv wp-config-sample.php wp-config.php

We will now provide our database information inside the configuration file,

$ vi wp-config.php

& make the following changes,

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */

define('DB_NAME', 'wordpressdb');

/** MySQL database username */

define('DB_USER', 'wpuseruser');

/** MySQL database password */

define('DB_PASSWORD', 'wppasswd');

We have now completed our installation & partial configuration of wordpress, but we have still not hosted the website & remaining configurations for the website will be carried out from the browser.
So open your browser & enter the URL

$ http://localhost/wordpress

You will now be asked to provide your site title, user name, password & email account.
Wordpress installation

After entering all the information, press 'install WordPress' button.You will now get a confirmation with success message.
wordpress installation
Now to login to the wordpress dashboard, click 'Log in' button & you will be redirected to a new page where you need to enter your username & password.
wordpress installation
Upon successful authentication, we will enter to wordpress dashboard. Here we can customize our website with plugins & themes, we can also upload posts, articles etc

Note:- if you don't want to have 'wordpress' at the end of the URL, you can move all the contents of /var/www/html/wordpress to /var/www/htm & restart the httpd service to implement changes.We can now access our website with just the IP address or the hostname of the server.

If you guys have run into nay trouble or want to suggest somethings, please feel free to use the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Become a Supporter - Linux TechLab is thankful for your continued support.