In previous posts I described how to install Lighttpd and PHP. Unfortunately I encountered some issues in getting this to work properly. So I had to spend a fair amount of time doing research on the web and trying different things before I got it right. I share my final work product here in hopes it will save you the time that I invested.
- Obtain the lighttpd Windows binaries from here. They were produced by the WLMP Project. I chose the .ZIP package without the setup since I wanted to do the installation manually on a USB Drive.
- Obtain the PHP binaries from here. Again I chose the first .ZIP package without the installer.
- Extract the LightTPD directory with all of it’s contents from the .ZIP file and copy it to your USB Flash Drive. I put mine in the root folder of my drive.
- Create a new php directory on the USB Flash Drive. I put mine in the E:\LightTPD folder of my drive. Copy the contents of the PHP .ZIP file into the php folder.
- Next I opened the [Drive]:\LightTPD\conf\lighttpd-inc.conf file and made all the necessary configuration changes. First I made sure the following modules were uncommented:
- mod_access
- mod_accesslog
- mod_alias
- mod_cgi
- mod_fastcgi
- mod_status
Assign the literal path to the http directory (in my case e:/lighttpd/HTDOCS) to the server.document-root variable.
Uncomment the server.port = 81 line since I would be using this on a machine already running Apache on port 80.
Uncomment the cgi.assign line and set .php = “e:/lighttpd/php/php-cgi.exe”
- Next I edited the E:\LightTPD\php\php.ini-recommended file. You could edit the php.ini-dist file if you prefer. I made a copy of the file, renamed the copy to php.ini and made the following changes:
Set display_errors = On (this is a development server)
Set extension_dir = “./ext” from it’s default of “./”. This was needed to make the extensions work properly.
Set cgi.fix_pathinfo = 1.
Made sure the following extensions were uncommented (removed the ; from in front of them):
- php_mbstring.dll
- php_mcrypt.dll
- php_pdo.dll
- php_sqlite.dll
You can also uncomment php_pdo_sqlite.dll if you want to use SQLite3. I had some difficulty getting the PDO calls to work so I started out with 2, but I will likely revisit this in the future.
- This next part was kind of unusual. I copied the php.ini file into the E:\LightTPD directory. Once I did this, PHP started working as a CGI, but it was REALLY slow. It would take 5 seconds to render a page on the local machine. To try and cure this I also put a copy of the php.ini file that I modified back into the E:\LightTPD\php directory and php started working as expected.
That was how I managed to get the 3 products working together on Windows (in my case Windows Vista Ultimate) and on a USB Drive (in my case a 1 GB Flash Stick). This was my first experience with lighttpd and SQLite, but I have used PHP extensively against IIS and Apache with MySQL on the back end. I am satisfied with the results, but not ready to call SQLite and Lighty my favorite servers ever. I am willing to say that they do a fine job of providing me with an easily portable development environment.
Peace


Thanks! This was exactly what I needed!