Webserver HowTo’s

Automate installation processes in WordPress

Free hosting

Many (free-) hosting providers offer installation scripts for some popular web applications like Drupal, Joomla, osCommerce, Coppermine or WordPress. I will restrict this article to the WordPress weblog application and more specific: the automated install in the free hosting option at service provider ‘Byet Internet Services‘. After registering, Byet offers a cPanel to manage the free hosting options. So, after registration and logging in to the cPanel, user is offered to create a free sub-domain and then using the ‘Software & Services‘ –> ‘iVista - Easy Script Installation‘, user can select to install WordPress to his sub-domain.

WordPress version

At the time of this writing, the resulting version of WordPress is: 2.8.5 whereas the actual latest version is: 2.9.1. Of course it would be nice to upgrade to the latest version immediately and most of all: EASY!?

WordPress offers an automated way to upgrade hassle-free, this option can be found in the WordPress-dashboard, with the link: ‘Please Update now‘. Using this feature, WordPress will offer a direct download- and upgrade process using your FTP-credentials, so you will not have to download-prepare-and-upload manually.

Unfortunately, the FTP-credentials of the Byet account don’t land at the WordPress installation in , so this process fails. A (relatively-) small modification makes for a work-around to this hurdle, we can change the WordPress installation to perform a direct file connection for this process.

This change requires to add some php-script code to be added to the file ‘wp-config.php’ which can be found in the main folder of your WordPress installation. So go ahead and use your FTP-client to download this file and open it in notepad for editing. Scroll down to the last line and add following 2 lines of code below, at the bottom of this file:

/** Override default file system method*/
if(is_admin()) {add_filter('filesystem_method', create_function('$a', 'return "direct";' ));define( 'FS_CHMOD_DIR', 0751 );}

Now, upload the file back to the server, overwriting the existing file. Now try again to start the automatic upgrade and it should work flawless! (Keep in mind: the change contains a check if the WordPress user is assigned to the group ‘Administrator’, so only those can perform this action!)

Uploads from WordPress

WordpPress comes with tons of features (which I’m not going to explain), some of which result in uploading to the server. One example is to add photo’s to a weblog while creating a new post. I have noticed that sometimes these uploads fail which usually indicates a problem with permissions to the specific folder on the server. Most important folder is the folder: ‘/subdomain.name.org/htdocs/wp-content/uploads’, where most uploads will land. So if this happens, first check the permissions of this folder. This can be done using your FTP-client, my favorite client is the FileZilla FTP client. Open the FTP-client, login to the server and browse to the folder. Then right-click on the ‘uploads’ folder and choose ‘File Attributes…” and make sure that all the Write permissions are activated (tickboxes). (I advise to activate the option to Recurse into subdirectories to make sure the rights are applied to all)

Sometimes, this might still not solve the uploading ‘problem’. In that case, it might be a problem due to php-restrictions. Often, webservers are configured to prevent more than one users writing to the same directory. In case the WordPress installation has been executed (server-side) by a different user than the user who handles the WordPress uploads, this might also cause the problem.

In case of this problem, we can add an exception-rule, which is done by using a ‘.htaccess’ file. To do this, open notepad and create a text-file with a single line:

php_flag safe_mode off

On windows-computers, it is usually not possible to save a file starting with a “.” (dot) in the filename, so choose in notepad for File - Save as… and save the file as “.htaccess” (INCLUDING the simicolons before- and after the filename). If you don’t manage to get the file saved this way, than just name it as you like. Now upload the file to the ‘uploads’-folder with your FTP-client and (if needed) use your FTP-client to rename the file on the server so it will become ‘ .htaccess’.

This should be all there is needed to make sure you (or your weblog-readers) will be able to upload to this folder! :)

Automated installation of Plugins

Now we get to the fun part of working with WordPress! WordPress can be modified/extended by installing plugins to add or change functionality to the site. The manual way would involve downloading the zip-file of a plugin, extracting the zip-file and then uploading all files to the server. This can be done automatically!

No Responses to “Webserver HowTo’s”

Care to comment?