WordPress is a free and open source blogging platform or content management system based on PHP and MySQL. Currently WordPress is the most popular CMS all over the world, and has 20000 plus plugins to extend its functionality.You can easily create a simple website, blog or complex portals and enterprise websites using WordPress.
WordPress provides lots of features. Some of them are listed below:
- WordPress is available in more than 70 languages. So you can build a website in a language as your choice.
- You can easily manage your content, schedule, look and publication using WordPress, and also secure your posts and content with a password.
- WordPress comes with thousands of themes for you to create a beautiful website. You can also upload your own theme with the click of a button.
- With the importers feature you can easily import your blog from another website to WordPress.
- WordPress provides search engine optimization out of the box, and also provides many SEO plugins.
In this tutorial, we will discuss how to install and configure WordPress on a CentOS 7 server.
- A server running CentOS 7.
- A non-root user with
sudoprivilege setup on your server.
Update your system with the latest package versions by running the following command:
sudo yum update -y
Once your system is up-to-date, you can proceed to the next step.
Before installing WordPress itself, you will need to install the LAMP stack and other required packages on your server.
You can install all the necessary packages with the following command:
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 installation is complete, start the Apache and MariaDB services and enable them to start at boot with the following commands:
sudo systemctl start httpd sudo systemctl start mariadb sudo systemctl enable httpd sudo systemctl enable mariadb
Configuring MariaDB for WordPress
By default MariaDB is not secured, so you will need to secure it first. You can do this by running mysql_secure_installation script:
Answer all the questions 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
Once you have finished, login to MariaDB console with the following command:
mysql -u root -p
Enter your MariaDB root password and hit Enter. After login, create a database for WordPress:
MariaDB [(none)]>CREATE DATABASE wordpress; MariaDB [(none)]>GRANT ALL PRIVILEGES on wordpress.* to 'user'@'localhost' identified by 'password'; MariaDB [(none)]>FLUSH PRIVILEGES; MariaDB [(none)]>exit
Installing and Configuring WordPress
You can download the latest version of the WordPress source from the official website. You can get the latest version of WordPress by running the following command:
Once download is finished, extract the downloaded file with the following command:
tar -xzvf latest.tar.gz
Next, move the extracted files to the Apache web root directory:
sudo cp -avr wordpress/* /var/www/html/
Next, create a directory for WordPress to store uploaded files:
sudo mkdir /var/www/html/wp-content/uploads
Next, assign proper ownership and permissions to your WordPress files and folders:
sudo chown -R apache:apache /var/www/html/ sudo chmod -R 755 /var/www/html/
Next, you will need to make some changes in the WordPress main configuration file, so it can be connected with the database and user.
First, rename and edit the WordPress main configuration file:
cd /var/www/html/ sudo mv wp-config-sample.php wp-config.php sudo nano wp-config.php
Change the DB_NAME, DB_USER, and DB_PASSWORD variables as shown below:
define('DB_NAME', 'wordpress'); define('DB_USER', 'user'); define('DB_PASSWORD', 'password');
Save and close the file when you are finished.
Accessing WordPress Web Installation Wizard
Before starting, you will need to allow access to the Apache ports using
You can do this by running the following command:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Next, open your web browser and type the URL
http://your-server-ip to finish the installation.