404 Tech Support

PHP Basics with WordPress and phpBB

With WordPress 2.7 hitting the market for self-hosted WordPress.org blogs, I’ve finally decided to make the jump. After reading some helpful tips regarding the 2.7 upgrade over at the Lorelle on WordPress blog, I began making my own preparations for the upgrade and ran into a little more technical issue.

Step 1 of the extended Upgrading WordPress instructions states to backup your database. Well, that’s a worthy idea anyways, but I was already using a very cool plugin, WP-DBManager, to take care of my database backups and optimization. I really recommend using this plug-in for this process and scheduling it to regularly optimize your database and e-mail you a back-up. I, unfortunately, had a little bit of a problem with my configuration, not the fault of the plugin that wouldn’t allow database backups to be made.

After installing and activating the WP-DBManager plugin, you can go to the Database tab that it adds to the top of your WordPress Admin pages to begin configuring it. Under the ‘Backup DB’ sub-tab, it gives you a status report if the backup process should have a greenlight. I was, unfortunately, getting a warning and backups would be created but would be 0KB in size. The warning I had:

passthru() disabled.
system() disabled.

Before my backups would work, I had to enable the PHP passthru and system functions. In order to do this, you have to change the configuration of the php.ini file. This file needs to be located in the directory that the script runs in; you can not put it in the top-directory and hope for it to have the effect on sub-folders. This gives you greater control over your configuration per-script.

All you have to do is create the php.ini file and upload it to your server in the directory with the script that uses those functions. For WP-DBManager you want to put it in the WP-Admin directory and the WP-Includes directory as it may also use these functions for other processes. If you need any other functions enabled, you can just remove them from the list in disable_functions.

phpBB

Another popular change to make in the php.ini file is to the maximum file size for uploaded files. This is particularly important in regards to phpBB as it dictates the maximum file size of attachments on your forum. By default, and in the above downloadable php.ini file, the largest file that can be uploaded is 2 Megabytes. As you can see below at line 488, the configuration is fairly straightforward.

To increase the maximum file size, just change the 2M to something larger like 10M (10 megabytes).

upload_max_filesize = 10M

Just open the php.ini file in your favorite text editor (I recommend Notepad++) and scroll down to that line (around line 488) and edit the file. Then save it and upload it to the directory that will contain the script for uploading files. For phpBB, this is the root directory or where posting.php is located.

PHP Info

One final function using PHP is strictly used for imaging gathering purposes. You can get a reading of your site’s PHP configuration by using a built-in function, phpinfo.

With your favorite text editor again, create a new file and insert a single line into it:

<?php phpinfo(); ?>

Then save the file as something with a .php file extension like phpinfo.php. Upload this file to a directory you want to see the configuration for and then browse to that new file in a web browser: www.yourdomain.com/phpinfo.php.

This will give you a listing of PHP’s configuration on your server, very useful information whenever you’re troubleshooting a PHP function. Things like the PHP version, configuration, function support, modules, variables, and the environment PHP is running in (your server). As an example of this function’s usefulness, you could use this on the same directory that you uploaded the php.ini file above to increase the maximum upload size and confirm that your changes are taking effect. Upload the phpinfo.php file to that directory and open a browser to the phpinfo.php file. Then just do a find on the page for upload_max_filesize and you should be pleasantly surprised.

With that slight detour done now, I’m ready to upgrade my WordPress blog to the latest version, 2.7.