In this tutorial you will learn how to install WordPress on CentOS 6. WordPress is a free and open source Content Management System, built on PHP and MySQL. It provides over 30,000 plugins for easy customization of appearance and functionality. WordPress is the most popular blogging platform, estimated to be running on 60 million sites and seen by tens of millions of people every day.
- This tutorial assumes that you already have LAMP (Linux, Apache, MySQL and PHP) installed in your server. If you don’t have LAMP stack on your sever, you can find the steps for doing the set up here.
- The user should have root privileges so as to have administrative capabilities and permissions. You can check out how to grant root privileges for user here.
Now that you have the user with root privileges and mandatory software, let’s get down to installing WordPress.
You can download the WordPress package directly from wordpress.org.
Before executing the download, verify whether wget is already installed on your server. You will have the WordPress package in zipped format inside user’s home directory. Unzip it using the command given below.
tar -xzvf latest.tar.gz
Create a Database and a User for WordPress
Once the WordPress files are unzipped, you can locate them under wordpress directory within home directory.
Now, log into MySQL shell using MySQL root password.
mysql -u root -p
Once logged in, you have to create a wordpress database and a user in that database. You can set a password for the new user. Find the MySQL commands for setting up the database and the user given below.
For creating the database:
CREATE DATABASE wordpress; Query OK, 1 row affected (0.00 sec)
Note: Here, I have given the name wordpress for the database. You can give any name you wish. However, a unique name is recommended.
For creating the user:
CREATE USER [email protected]; Query OK, 0 rows affected (0.00 sec)
For setting the password for the user:
SET PASSWORD FOR [email protected]= PASSWORD("yourpassword"); Query OK, 0 rows affected (0.00 sec)
Note: Here, I have given the name wordpressuser1 for the newly created user. You can set password as you prefer.
Now, you can grant all the privileges for the new user. Without proper privileges, you may end up with installation and database permission issues.
GRANT ALL PRIVILEGES ON wordpress.* TO [email protected] IDENTIFIED BY 'yourpassword'; Query OK, 0 rows affected (0.00 sec)
Finish up this step by refreshing and exit out of the shell.
FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) Exit
Configure the WordPress Installation
Here we are going to set up WordPress and link it to the database that we created for it.
For that, first you need to locate the sample wordpress configuration file from the wordpress directory and copy it to a new file which you can edit later. Thus a new usable wordpress config will be created.
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Open the wordpress config for editing.
Search for the code snippet that contains MySQL settings and update the name of database, username and password correctly.
// ** 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', 'wordpressuser1'); /** MySQL database password */ define('DB_PASSWORD', 'yourpassword');
After updating the fields, save and exit.
Copy the WordPress Files
We need to move the unzipped wordpress files to website’s root directory.
sudo cp -r ~/wordpress/* /var/www/html
Now, we are almost done with the WordPress upload to the server. All we need to do is complete the online installation for it.
But the form requires specific php module to run. If php-gd is not yet installed on your server, do that using yum command:
sudo yum install php-gd
Now, restart Apache:
sudo service httpd restart
Access and Finalize the WordPress Installation
This is the last stage of your WordPress installation. Open your browser and access the page by tailoring your site’s IP address or domain with /wp-admin/install.php. The link may look like this:
The WordPress online installation page will be opened and it should look similar to this:
Fill out the required fields in the form and finalize the WordPress installation.