Sunday, December 30, 2007

Installing PHP 5.2.5 on Windows XP for Tomcat 6.0.13 - Issues resolved

I was playing around with the idea of doing a small personal PHP project, and I decided to do a fresh install of the latest version of PHP, which is 5.2.5. Since I'm already using the Apache Tomcat 6.0.13 server, I decided to run PHP on that instead of setting up the Apache HTTP server. I've done something similar before, so I didn't think it would be much of a problem. However, it is a bit more tricky than expected.

Windows PHP installer is broken

Initially, I used the Windows installer. The PHP install directory used was "C:\Program Files\PHP". Installing was a breeze and I could even use the php5srvlt.jar and put it into the WEBINF\lib directory without doing anything. The reflect.properties and servlet.properties files already have the line

library=php5servlet

instead of

library=phpsrvlt

So I followed the steps outlined. When I tried to access the test page, I got this.
HTTP Status 500 -
type Exception report

message
description The server encountered an internal error () that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet php threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
.....(edited for brevity)

root cause
java.lang.UnsatisfiedLinkError: C:\Program Files\PHP\php5servlet.dll: Can't find dependent libraries
java.lang.ClassLoader$NativeLibrary.load(Native Method)
.....(edited for brevity)

I checked the install directory and php5servlet.dll was there. What are the dependent libraries? After reading some of comments on Angusman's site and some discussions on Java forums, it turns out that the problem is due to missing DLLs. I downloaded a tool called Dependency Walker. It is very useful, I loaded php5servlet.dll and got the following.

Dependency Walker says php5ts.dll is missing

So php5ts.dll is missing. Searched for the file on PECL4WIN but could not find it. So I downloaded the zipped PHP files, then I noticed that there is an error in the original installer for PHP 5.2.5. Apparently the updated installer still has issue.

Steps I took to get it working

  1. Uninstall the initial install and remove all the files in the install directory

  2. Unzip the downloaded PHP zipped file into the install directory.

  3. Download php5servlet.dll from PECL4WIN and put it in the install directory. If you don't have it you will get an error message like:
    exception
    javax.servlet.ServletException: Servlet.init() for servlet php threw exception
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    .....(edited for brevity)

    root cause
    java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path
    java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
    .....(edited for brevity)


  4. Edit the following paths in the php.ini file: include_path = "C:\Program Files\PHP\PEAR", doc_root = "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.13\webapps", extension_dir = "C:\Program Files\PHP\ext"

  5. Uncomment a few extensions in php.ini and ensure the DLLs are in the extension directory, eg curl or bz2

  6. Save the php.ini file.

  7. If you right-click and php.exe, php-cgi.exe and php-win.exe and see the properties, you will see this message "Security: This file came from another computer and might be blocked to help protect this computer." I chose to unblock, but I'm not sure if there's any issue leaving it on.
    Security message

  8. Create web.xml, php5srvlt.jar and test page like what Angusman says in the appropriate directory in the webserver. If php5srvlt.jar is not in the correct directory you'll get an error message like this:
    exception
    javax.servlet.ServletException: Wrapper cannot find servlet class net.php.servlet or a class it depends on
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    .....(edited for brevity)

    root cause
    java.lang.ClassNotFoundException: net.php.servlet
    .....(edited for brevity)

    I already have them so I skipped this.

  9. Create the following environment variables PHP_HOME="C:\Program Files\PHP", PHP_HOME_EXT="%PHP_HOME%\ext", PHPRC="%PHP_HOME%". PHPRC is used to determine the location of the php.ini file but it is not the only place where it can be set. The locations being searched for the php.ini file follows a certain order. For my purpose this setting PHPRC is sufficient. If this is not set, the default location will be used, and may result in php.ini not being loaded, which in turn results in the configuration settings being set to some unexpected values, modules not being loaded as seen in phpinfo(), etc. Some examples.

    Wrong include path
    Wrong include path
    Wrong extension directory
    Wrong extension directory

  10. Append the environment variables to the PATH environment variable.

  11. Reboot so that the PATH changes are set. If not, you'll get some error like this where the environment variable appears correctly on it's own but not in the PATH.
    Computer needs to be rebooted for PATH changes to be effected

Sunday, December 16, 2007

High Street 5 - Dance up your life

I was going to Funan to get some stuff when I saw this banner for a game called High Street 5. The banner had an attractive lady drawn on it so that's what caught my attention :p Then I took a closer look and realised it was some sort of dancing game. I'm not into dancing, and I've not even played the famous Audition SEA. But since I was bored I got a copy of the DVD client at 2 bucks. (Alternatively, you can download it. It's free to play.) Here's a preview of the game:

[youtube]ECc0a22zcnE[/youtube]

Startup pain and an unintuitive user interfaceInstallation was simple, but getting to actually play the game was a tad more difficult. First I was required to download a patch to version 0.12 when I tried to start the game. But the user interface showed some IE page with a message on it. No go trying to update it by clicking on the "Update Server" button either. I had to go to the website and download the patch. After installation, I had to reboot as there was still a connection problem.

Then when I tried to register an account in-game, Windows Internet Explorer popped up and I was directed to the website to register an account. That's not a seamless experience but it's still not very annoying.

The worst part is that the user interface is not intuitive at all. I couldn't figure out how to get started after registering an account. The instructions said something about clicking some part of the screen, so I spend a good couple of minutes figuring out where exactly that part is. Out of frustration I went to the forum and finally got some help from one of the posts there. Now, any game that makes me do that gets an immediate poor rating for user experience.

Finally I get to play

After getting into the game, there's the standard character creation, choose name, sex, physical characteristics, etc. The story is supposed to be that you are talent-scouted for some agency or something. Not exactly intriguing but who cares about the story in this kind of game anyway? After initial part of the story gets out of the way and you are taught the basics of the game (hit the directional, space and some number buttons at the right time), you get to choose certain locations to dance in,like the school, beach, etc. As you get better more areas will open up to you.

And it's quite fun actually to see your character groove to the music along with the rest of the players. Here's a replay of one of my game sessions. The parts when the character is just standing around are the parts where I missed :)

[youtube]bKDm6W0ma_s[/youtube]

[youtube]yErxF1qVumc[/youtube]

Summing up

It's a simple and addictive game. Currently the selection of songs is somewhere ard 30-40 I think, so you'll here the same songs being recycled ad nausem if you do play long enough. Hopefully they will add more songs to the library else it'll get boring after a while.

Monday, December 10, 2007

Switched webhosting to Godaddy

Finally switched my webhosting to Godaddy, it's value for money in terms of disk space, but the everything seems slower than Focushub.

Sunday, December 2, 2007

Sitex 2007

Needed to get some computer stuff, so hopped down to Sitex to pick up some bargains.

Some stuff I've gotten:

HP F4185 AIO printer, scanner, copier - $99 (Usual price is $149. Challenger members can get it at $139, so the savings at this show is quite significant)

Maxtor One Touch 3 - $130 (Not sure if I saved much on this buy)

Disk repairer for CD/DVDs - $25

Quite happy with my buys, but I spent quite some time installing the AIO. During the installation, the program got stuck, some error message about unsigned drivers and USB printing. Downloading the latest installation frpm the support website didn't help. In the end, what happened was that when I was prompted to plug in the USB cable, DON'T! Wait for the installation to complete, THEN plug in the USB cable.