Installing WordPress on CentOS 5/6
Article ID: 3643
Last updated on August 14, 2013
Authored by: Kyle Laffoon
WordPress is a content management system originally developed for blogging, but has beed greatly expanded through widgets, themes and plugins. Complete the following steps to install WordPress on a CentOS 5/6.
Pre-reqs
Clean installation of CentOS 5/6, MySQL, Apache and PHP on your server.
WordPress software from http://wordpress.org/download/ uncompressed in a local repository
User needs to have root privileges and be logged in as root or su.
System packages installed:
yum -y install mysql-server httpd php php-mysql unzip wget
chkconfig httpd on
chkconfig mysqld on
/etc/init.d/mysqld start
/etc/init.d/httpd start
Create a WordPress database and MySQL User
Note: After the wordpress files are unzipped, they will be in a directory called wordpress in the home directory.
Log in to the MySQL Shell and create a new MySQL directory for wordpress
mysql -u root -p
After logging in using your MySQL root password, create a WordPress database:
(For this example, we will use the database name WordPressdb.)
CREATE DATABASE WordPressdb;
Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:
CREATE USER wordpressuser@localhost;
Set the password for your new user:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
Note: For security purposes, you would obviously not use “password” for your password. Be sure to assign a secure password in this line instead.
Grant all applicable privileges to the new user. Without this command, the wordpress installer will not start up:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
Refresh MySQL:
FLUSH PRIVILEGES;
Exit out of the MySQL shell:
exit
Configure WordPress
Copy the sample wordpress configuration file from the wordpress directory, into a new file.
Edit the new file to create a new usable wordpress config file:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Open the wordpress config:
vi ~/wordpress/wp-config.php
Find the section that contains the field below and substitute in the correct name for your database, username, and password:
// ** 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', 'wordpressuser');
/** MySQL database password */ define('DB_PASSWORD', 'password');
Save and Exit.
Copy the Files
Transfer the unzipped WordPress files to the website’s root directory.
sudo cp -r ~/wordpress/* /var/www/html
Install the following php module on your server, to enable the WordPress installation form online. Download php-gd:
sudo yum install php-gd
Restart Apache:
sudo service httpd restart
Confirm setup
Review your new set up at http://your-server-ip-or-hostname/wp-admin/install.php