A Path Less Taken

Breaking with convention in a very conventional fashion. Powered by WordPress

"What would you attempt to do if you knew you could not fail?"
Dr. Robert Schuller

Sunday, February 15, 2009

Category: Web Development Author: JJ 1 Comments

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.

  1. 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.
  2. Obtain the PHP binaries from here. Again I chose the first .ZIP package without the installer.
  3. 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.
  4. 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.
  5. 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”

  6. 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.

  7. 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

One Comment to “Installing Lighttpd, PHP and SQLite on a USB Drive”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">