Select Page

A while back, I posted an article on building your own DIY webserver from scratch, using ClearOS.   ClearOS, is a fantastic distribution, but it does require some tweaking in order to run your favourite PHP based apps such as WordPress or Zen Gallery due to the default permissions structure. Read on to find out how to get these running like a charm.   This article assumes that you already have your ClearOS installation up and running, and have started up the Web Server and MySQL portions of ClearOS.

The first port of call in this article, is pulling down the latest edition of WordPress.   For this article, I’m going to use default folders for simplicity’s sake.   Using an SSH client (my preference is PuTTY), connect to your ClearOS system and enter the following commands to pull down and extract WordPress.

cd /var/www/html
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

WordPress will now have been extracted to the default ./wordpress/ folder.   If you navigate to your WordPress site in a browser, you will be greeted with the following:

Your server is running PHP version 5.1.6

Wordpress Requires PHP 5.2 or Higher

As you can see, we need to upgrade the PHP version. Uninstall the current version of PHP with the following command:

yum remove php-common

This will remove PHP 5.1 and all its dependencies. Now let’s install PHP 5.3 using the following:

yum install php53 php53-cli horde-imp php53-mysql php53-ldap php53-mbstring app-horde php53-pdo php53-common

I have left out the php53-imap package from the above as it has a dependency issue that I can’t seem to resolve, however this is not a package that we will be requiring for WordPress.   I stand to be corrected, but it does not seem to affect Horde either if you are using the Webmail portion of ClearOS.   Once you have installed PHP 5.3, you need to restart Apache and MySQL (otherwise phpMyAdmin will not work).   You can do that with the following commands:

/etc/init.d/httpd restart
/etc/init.d/mysqld restart

If you refresh your browser, you will now get the WordPress first run wizard (as per below):

Create wp-config

Looking good so far

When you complete all the settings however, you will get an error that the files could not be written as per the screenshot below.   You could go and edit the file manually, but you will still get problems down the line when trying to write any files such as themes etc.

Setup Error

Could not write to wp-config

The problem here is that the Apache hosting folders, by default, are assigned to another user id.   Changing this is very easy with either WinSCP or in the command line with PuTTY.   If you want to go the GUI route and use WinSCP, your first step is to see which uid Apache is using and which group it is part of.   At this point, I feel it is important for me to say that the below is more a “for interest’s sake” considering you are already in the command line, so WinSCP is really the long way round.   To get the uid and gid, run the commands below:

awk -F”:” ‘{ print “username: ” $1 “ttuid:” $3 “ttgid:” $4 }’ /etc/passwd

This will return a list of users and their corresponding ID’s, you will be looking for the Apache user and group.

awk command for uid and gid

Username, user ID and group ID


In this case, it is uid 48 and gid 48.   Add these in to WinSCP’s permissions window recursively for the /var/www/html/wordpress directory, and off you go!

WinSCP Permissions

WinSCP Permissions

Alternatively, there is a much quicker command you can run from the command line, which is as follows:

chown -R apache:apache /var/www/html/wordpress

Now, if you go back in your browser and re-submit the details, you should be good to go! (Told you WinSCP was the long way…)

Successful WordPress Installation

Success!

And that, is how you get WordPress installed on ClearOS 5.2! Happy publishing!