Site Search
Homepage of Otaku No Zoku
Complete Archives of Otaku No Zoku
About Otaku No Zoku
Subscribe to Otaku No Zoku
Bookmark Otaku No Zoku

WordPress And EasyPHP on Windows 7 :

For the past few years I have been using the InstantRails package as my workhorse for developing PHP applications. Not sure why it started that way, but that’s how it has remained for quite some time. Today I took it in to my head to try out EasyPHP to see if it suited my needs.

EasyPHP uses the latest version of Apache, PHP, mySQL, and a few other bits of software, so it is a bit more up to date for my development needs than sticking with InstantRails which happens to be ideal for Ruby but not so much for PHP.

I was excited to see that EasyPHP supposedly supported WordPress with the addition of a simple add-on module, but… according to the EasyPHP website and several forum posts, EasyPHP and WordPress will not work under Windows 7 which is a bit troubling. Even more troubling, I have Windows 7 64-bit, so that brings with it a whole new set of circumstances. True enough, EasyPHP does not play well with WordPress straight out of the box, but a few simple configuration changes make it work perfectly. I’ll detail those step by step changes below. Fortunately for me and you, these changes work on either 32-bit or 64-bit Windows 7 so it doesn’t matter which version of Windows 7 you happen to have.

In this quick tutorial, the tag <easy php dir> means you should replace that with where ever you installed EasyPHP.

2SENSECAM-0010 There are five specific types of change you need to make for WordPress and EasyPHP to work harmoniously together: Fix EasyPHP, fix PHP, fix Windows, fix WordPress, fix Apache.

 

Fix #1 — Fix EasyPHP

Apache does not like spaces. I have no idea why EasyPHP does this, and I am sure on many systems it does not cause an issue, or the EasyPHP maintainers have some secret sauce that makes Apache behave itself, but Apache, by default, does not like path names with spaces. In some cases it will happily digest a space character in your path name, in many others it’ll aggressively throw an error, and in a few rare instances it will quietly do something completely unexpected and royally screw you.

When you install EasyPHP, and the beauty of EasyPHP is that you don’t have to install it, so it can easily be copied to a memory stick, is make sure you do not have any spaces in your path names leading to either the Apache executable, the Apache configuration file, or the document directory where Apache will serve up your web pages from.

The easiest way to solve this problem is that when you use the EasyPHP installer, change the default directory from C:\Program Files (x86)\EasyPHP to something like C:\EasyPHP, or alternatively C:\Users\Public.

There is another reason for doing this, with Windows 7 locking down access to certain directories for users without the right privileges, when it comes time to update the configuration files or edit the files for your website, you cannot do it inside of the program files directory. If you play World of Warcraft you’ll know that Blizzard now puts the WoW game client directory inside of \Users\Public so that it can be updated and patched without it causing user permissions problems. Do yourself a favour and do the same with EasyPHP.

Fix #2 — Fix PHP

The PHP that comes with EasyPHP by default does not permit the short open tag inside of PHP files, i.e. <?= code here ?>, instead of the more formal: <?php code here ?>.

Many themes, functions and plugins in WordPress make use of the short open tag feature, so you need to enable that.

You need to edit your PHP initialisation file located in <easy php dir>\conf_files\php.ini and find the following line:

short_open_tag = Off

Which then needs to be changed to:

short_open_tag=On

Fix #3 — Fix Windows

The behaviour of Windows 7 has changed slightly in how it handles localhost. Previous versions of Windows had the "127.0.0.1 localhost" line in the hosts file by default, and without that being there, many older applications, EasyPHP being one of them, gets easily confused. Even if you can get EasyPHP installed and working and connecting to the database via the phpMyAdmin at 127.0.0.1/home/mysql your WordPress blog still won’t connect because the wp-config.php will most likely be using localhost. Hence, you will most likely receive just a blank page or a database connection error message if you are really lucky.

Windows stores its hosts file in C:\Windows\system32\drivers\etc so the quickest way to edit it is to open up either the run dialogue or a command prompt and issue the following command:

notepad c:\windows\system32\drivers\etc\hosts

Just after the initial comments, you should see the line: # 127.0.0.1 localhost

Remove the hash sign (#) from the start of the line, save your hosts file, and exit notepad.

Fix #4 — Fix WordPress

Most likely your WP-CONFIG.PHP file in the <easy php dir>\www\ directory is using "localhost" to connect to the database. You need to change this so that it uses 127.0.0.1. Don’t ask me why but on two identically configured Windows 7 machines, one was okay with using "localhost" and the other one demanded the use of "127.0.0.1" to connect, but 127.0.0.1 on both seems to work fine so that’s what I am using now.

In WP-CONFIG.PHP, which is located in <easy php dir>\www\ and edit the line that reads:

define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

So that it instead reads:

define('DB_HOST', '127.0.0.1'); // 99% chance you won't need to change this value

Fix #5 — Fix Apache

Apache needs to have two changes made to it if you want your fancy permalinks and pretty URLs. To do this, you need to load the rewrite module, and then give permissions to WordPress to actually make use of it.

To enable the rewrite module, you need to edit your Apache configuration file, which lives in <easy php dir>\conf_files\ and is named httpd.conf

Find the line that reads:

# LoadModule rewrite_module modules/mod_rewrite.so

And remove the hash sign (#) from the start of the line, so that it reads:

LoadModule rewrite_module modules/mod_rewrite.so

The second change is a permissions change, again in the <easy php dir>\conf_files\httpd.conf file.

Find the line that reads:

<Directory "${path}/www">

Then look a few lines down from that line to find the line that you need to change, which reads:

AllowOverride None

Which should be changed to:

AllowOverride All

Save your httpd.conf file

After those changes you should be ready to start up the EasyPHP application and enjoy WordPress and EasyPHP running on Windows 7.

To be on the safe side I suggest regenerating your EasyPHP configuration files through the EasyPHP control panel just in case Apache does not pick them up. To do this: Stop the servers (F3), regenerate the configuration files (Right click EasyPHP icon in task bar, select “Configuration\Regenerate conf files”, and then finally start all of your servers again (F2).

Liked This Post?

Subscribe to the RSS feed or follow me on Twitter to stay up to date!