HOWTO: Installing lighttpd, PHP, and MySQL on Windows XP

I recently had to change computers at work because of a hardware failure. Unfortunately, my new one is a somewhat less capable. The biggest issue is the lack of RAM (only half a gig? That’s practically useless! And what’s up with Dell getting rid of PS/2 ports?). Anyway, I had an older version of XAMPP running on the old one for internal use and found that Apache can be a bit of a memory hog. Also, I was using the Python plug-in and it seems like they stopped development on that. I had no particular reason to stay with XAMPP anymore.

It was time to try a different web server, one that was a little less weighty (okay, that’s an awful pun). I had looked at lighttpd in the past but no Windows binaries were available. However, there is one maintained here (v1.4.11). (Here’s a new link, the website was changed)  Installation was fast and simple, although it would have been nice to pick the install directory. However, I didn’t have to compile it, so I won’t complain too much. It worked right away, and the sample page was up and running.

Next, I installed the latest version of php (5.1.6). That wasn’t too difficult. I followed the manual installation instructions and had a working php installation. I didn’t need to make any changes to php.ini. Well, actually, I didn’t think I needed to make changes.

The next hurdle was to get php and lighttpd working together. There’s a page here that has instructions for integrating them. FastCGI allegedly doesn’t work with Windows and lighttpd so I am using it in cgi mode for now. It requires activating mod_cgi and adding the proper cgi.assign in lighttpd.conf. There is also a small change required in php.ini. I needed to add the line cgi.fix_pathinfo = 1. To test it, I made a test.php file with three lines:

<?
phpinfo();
?>

At first, browsing to my test page returned a blank page. Well, that’s pretty much useless. After reloading the page and restarting the server multiple times, I looked at the source of the blank page. Since I saw the raw php code, I realized (surprise) that my configuration was incorrect. In my quick scan of the default php.ini file, I left the short_open_tag variable Off. I changed that to On and then it worked.

The third part of my installation was a database. I was using MySQL, so I decided to stick with that. I got the newest version (5.0.24a) and started the installation. This one didn’t go quite so smoothly. The last part of the installation involves running the Server Instance Config Wizard. I went through the detailed configuration and for some reason, it didn’t apply the security settings at the end. If I went back and forward again, it got stuck on the Create Service step. I saw that the service was already there but not configured correctly. Eventually, I figured out that I should delete the service and enable the TCP access in the Config Wizard. Then it was successful.

Now, I wanted to transfer some of the old web pages to the new server. For some of them, I used mod_alias because they were just static files and they could stay in the old location. I also wanted to transfer Drupal and that wouldn’t work the same way. My first step was to back up the Drupal database. That was easy enough using phpMyAdmin on the old setup. Then I had a thought which maybe wasn’t so bright at the time. I decided to install phpMyAdmin (2.8.2.4) for the new web server. It wasn’t that difficult, I guess, but I did find out that I missed a step earlier. For some reason, it wasn’t connecting to the database and complaining that php_gd2.dll wasn’t loaded, even though it was activated in php.ini. I wasn’t sure why until I ran php -v from the command line. I saw errors that started with “PHP Warning: PHP Startup: Unable to load dynamic library ‘./php_mysql.dll'” It turns out that I neglected to the change the extensions directory in php.ini. The default of ./ just wasn’t working since they were actually in c:/php/ext. That fix was easy enough. With phpMyAdmin working properly, I imported the Drupal database and then copied the htdocs/drupal directory to the new location.

Drupal was working! Well, not quite yet. The front page worked, but every link I clicked on gave me a 404 error. I did a search on the Drupal website for 404 and found the solution quickly. I found this comment about the rewrite rules for lighttpd. Adding the suggested lines to lighttpd.conf and enabling mod_rewrite solved the problem. I believe it has to do with the clean url option in Drupal. Now, all the pages appear correctly but files that I uploaded previously are not available. I haven’t found a solution for that yet but I haven’t looked enough yet. The solution could be here, though. Or maybe not. I don’t have that many files, so I might just upload them again. And I might as well upgrade to 4.7.3 first.

Advertisements

One thought on “HOWTO: Installing lighttpd, PHP, and MySQL on Windows XP

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s