Josh Dick portrait Josh Dick

Setting up LightTPD with PHP, MySQL, and Perl on Windows 2000/XP

Seting up a LightTPD development server environment on Windows.

Part 1: Before you Start…

So, you want to get a personal web server up. And you want to be different and do the installation yourself, without relying on something like XAMPP (not to mention actually abandoning the RAM-guzzling Apache web server altogether.) Enter LightTPD. Its website simply describes the program this way: ‘Light footprint + httpd = LightTPD’. LightTPD is a small, fast, open source web server for various platforms (primarily POSIX compatible operating systems) that is released under the revised BSD license.

This tutorial will attempt to explain how to get LightTPD running and working with PHP and MySQL on Windows XP and 2000 machines. I wrote it because I couldn’t find any other decent tutorial that explained how to get it all working all in once place. After a lot of tinkering, finally getting everything working, and then being very impressed by LightTPD’s performance, I decided I had to share the wealth. This tutorial is meant for absolute beginners, and I tried to write as simply as possible. If you have some Apache configuration experience, this should be cake. If not, I hope it’ll still be cake.

Alright, it’s time to get your toes wet.

Part 2: Tools of the Trade

You will need all of the following programs and packages at your disposal before we begin, so you might as well bite the bullet and download them all. Don’t worry, they’re free.

  • LightTPD. LightTPD is the actual web server program itself. As of this writing, Windows builds of LightTPD (packaged as a Windows executable installer) are currently available for download at Kevin Worthington’s blog, and the current stable version of LightTPD is version 1.4.11.

  • PHP. You also need to download PHP. Just the ZIP package of the Windows PHP binaries is needed (NOT the Windows executable installer, and not the PECL modules package.) As of this writing, the current stable version of PHP is version 5.1.4.

  • MySQL. As of this writing, the current stable version of MySQL is version 5.0.21, and it can be found at MySQL’s download page. Make sure you get the ‘Without Installer (unzip in C:)’ ZIP package. Download the plain one, not the AMD64/Intel EM64T package, unless you know you’re doing. These instructions were not tested with the 64-bit version of MySQL, but I don’t see any reason why the 64-bit version wouldn’t work (assuming your computer has a 64-bit processor.)

  • Perl. For this tutorial, we’re going to be using ActiveState’s Perl package, ActivePerl. As of this writing, the current stable version of ActivePerl is version 5.8.8.817, and it can be found at ActivePerl’s download page. Make sure you get the ‘Windows AS Package’ ZIP package.

  • phpMyAdmin. As of this writing, the current stable version of phpMyAdmin is version 2.8.0.3. phpMyAdmin is not necessary to get the server running, but if you’re a beginner (the intended audience of this tutorial,) you’re most likely not going to interact with MySQL using the DOS terminal; phpMyAdmin is a must if you’re a beginner. Most professional web hosts provide phpMyAdmin as a frontend for MySQL, so even if you’ve never heard of it, you’ve probably seen it before. You can download phpMyAdmin from its website. (Look on the top left of the page for the link to the latest stable version.) It doesn’t matter which of the three phpMyAdmin packages you download. Seeing as you’re a Windows XP or 2000 user, you should definitely be able to extract ZIP files, so you can’t go wrong with the ZIP package.

The downloading part is now over. Before you begin installing and configuring everything, however, there are some things you should know and do.

  • Turning on file extensions in Windows, if you don’t already have them on, is a must. To do so, click the ‘Start’ button, click ‘Run’, and then type ‘explorer’ in the box (with no apostrophes.) Click on ‘Tools’ on the menu bar, and then select ‘Folder Options…’. Click on the ‘View’ tab on the window that will appear. Make sure the ‘Hide file extensions for known file types’ checkbox is unchecked, then hit ‘OK’. Please do this before continuing.

  • Whenever this tutorial mentions ‘commenting’ or ‘uncommenting’, it means either adding or deleting either a semicolon ‘;’ or hash ‘#’ at the beginning of a named line in a text file. You will be able to tell which character is needed simply by context (you’ll see other comments in whatever file you’ll be editing,) but if you absolutely must know, the PHP configuration file uses ‘;’ for commenting, and the LightTPD configuration file uses ‘#’ for commenting. More on that later.

  • Whenever this tutorial mentions ‘changing variables’, it usually means changing something in between two apostrophes or quote marks on a named line, or changing the word ‘Off’ to the word ‘On’ on a named line (or vice versa. Use similar case when changing these words, just to be safe.) Make sure you use a plain text editor like Windows Notepad or Windows Wordpad, and NOT something like Microsoft Word. (I personally like Notepad++) to edit files that need editing in this tutorial, to prevent things like smart quotes from being automatically added (those are a big no-no,) or to prevent incorrect information from being added to the files in general. Also try to keep track of your file extensions…make sure your text editor doesn’t append the .txt to every file you save, and when editing a file, save as type ‘All Files’.

Part 3: The Plan

If you’re not a total beginner and just want the basic steps to get everything working outlined for you, here they are. If you’re confused by any of these steps, they’re explained in great detail below, so feel free to keep on reading if you’re confused.

  1. Install lighttpd, using the installer’s default options. Uncheck the ‘Start LightTPD’ checkbox at the end of the installer.

  2. Extract the PHP ZIP package inside the c:\lighttpd directory so that you have C:\lighttpd\php\php.exe, MySQL so you have C:\lighttpd\mysql\bin\mysql.exe, and Perl so you have C:\lighttpd\perl\bin\perl.exe. You can also extract phpMyAdmin into C:\lighttpd\htdocs if you wish.

  3. At the top of the LightTPD configuration file located at ‘C:\lighttpd\etc\lighttpd.conf’, add this line:

    cgi.assign = ( “.php” => “c:/lighttpd/php/php-cgi.exe”, “.pl” => “c:/lighttpd/perl/bin/perl.exe”, “.cgi” => “c:/lighttpd/perl/bin/perl.exe” )

  4. Scroll down and uncomment the lines for the CGI and SSI modules.

  5. If you want directory listings on, uncomment this line:

    dir-listing.activate = “enable”

  6. Rename C:\lighttpd\php\php.ini-dist to php.ini, and open this file. Inside this file, change the extension_dir parameter from ‘./’ to ‘./ext’. Uncomment the appropriate extensions–I reccomend uncommenting the mbstring, curl, imap, mysql, and openssl extensions at the bare minimum.

  7. Start the MySQL server by running C:\lighttpd\mysql\bin\mysqld-nt.exe, and then once the server’s running, set a root password by running mysql -u root in a DOS prompt, and entering the line set password = password("your_password"); at the MySQL console.

  8. Start the server with the shortcut in the start menu or in the C:\lighttpd folder.

That’s it. If you need help configuring phpMyAdmin, see below.

Part 4: Getting your Hands Dirty

Part 4 assumes you didn’t follow any of the steps in Part 3 and that you’re starting fresh after completing/reading parts 1 and 2.

Do the steps above look slightly scary? Are you still ready to get all of this stuff installed and working? Good, I thought so.

Part 4a: Installing LightTPD

Start by running the LightTPD installer. Installation is fairly straightforward. I recommend installing the server into the default directory C:\lighttpd\–that is the only directory these directions have been tested with. If you choose another directory, not only will you be on your own and have to modify these instructions as you go (for your custom directory,) but it’s not a good idea because long Windows directory names tend not to play very nicely with PHP (after you eventually install it.) You’ve been warned. You can leave the checkbox that is on the installer’s final screen (the screen with the ‘Finish’ button) checked. Assuming LightTPD is installed and you left that checkbox checked, LightTPD should now be running (it runs in the background and doesn’t have icons you can click on–this kind of program is called a daemon, which is what the ‘d’ stands for in ‘httpd’.)

Try accessing the server by going to the IP 127.0.0.1 in a web browser (type it directly into the address bar.) If the LightTPD welcome page doesn’t load, a firewall program running on your computer may be preventing the server from starting properly. Try disabling all firewalls (including Windows firewall.) If you determine that a firewall is causing issues, create an appropriate firewall exception for a web server so that you can run the firewall and LightTPD concurrently. (An explanation of the process of creating firewall exceptions is beyond the scope of this article.) In any case, don’t proceed until you’re able to connect locally.

Obviously, you also need to confirm that remote computers are able to access your web server. Figure out what your external IP is by going to whatismyip.com or a similar site. Type that IP into your browser’s address bar. If you don’t see the LightTPD welcome page, there are several possible causes. You may have a firewall enabled and need to disable it (or create appropriate firewall exceptions.) It could also be possible that your ISP blocks access to web servers running on TCP port 80 (the standard port for web servers.) Don’t worry if this is the case; there are ways to get around this that will be discussed later. Finally, the problem could be that your computer is connected to the Internet through a router, and the router needs to be configured to forward traffic on port 80 to your machine on the network. All of the web pages served up by LightTPD are stored in the C:\lighttpd\htdocs folder. Everything that’s currently there can be deleted and replaced with your own pages and files, if you wish.

Part 4b: Installing and configuring PHP

The LightTPD installer should have made shortcuts to the server program in your Start Menu, but those shortcuts only start and stop the server. We need to start editing its configuration. Find the PHP zip file you downloaded before, and extract it somewhere. Open the folder in Windows Explorer, and rename the top level directory (the one containing php.exe, as well as other files) to simply, ‘php’. Move the ENTIRE FOLDER (NOT the folder’s contents) to the C:\lighttpd directory. The path to php.exe should now be C:\lighttpd\php\php.exe. Navigate to the C:\lighttpd folder, and double click on the ‘stop-lighttpd’ shortcut (this does the same thing as the Start Menu shortcut.) Now, in your text editor (see Part 2,) open the file C:\lighttpd\etc\lighttpd.conf. You might have to select the ‘All Files/Documents (*.*)’ filetype in your editor’s open dialog to be able to access the file with the editor. At the very top of the file, add a line that says this (you can copy and paste:)

cgi.assign = ( ".php" => "c:/lighttpd/php/php-cgi.exe" )

If you haven’t been following this tutorial exactly, and installed LightTPD in a different directory, you’ll have to adjust the path given above, but please keep in mind that THIS PATH MUST USE FORWARD SLASHES (‘/’,) and NOT backslashes (‘'.)

Scroll down, and locate the lines containing the text "mod_cgi" and "mod_ssi". Uncomment both of these lines (see Part 2.) If you want the server to display a directory file listing instead of an error message when it doesn’t find a default file (such as index.php) in a folder in the htdocs directory, you can uncomment the line in the lighttpd.conf file that reads dir-listing.activate = "enable". Finally, if you were one of those people whose ISP was blocking web server access, uncomment the line in the file that contains #server.port = 81. Don’t uncomment this line if you were able to access your server using your external IP (the one that wasn’t 127.0.0.1).

Next, rename the file C:\lighttpd\php\php.ini-dist to simply ‘php.ini’. Open this file in your text editor. Locate the line that reads extension_dir = "./". After the ‘./’, add ‘ext’, so that the line reads extension_dir = "./ext". Also uncomment these lines to enable popular PHP extensions (if you know what you’re doing, you can ignore this list and enable extensions as you see fit:)

extension=php_mbstring.dll
extension=php_curl.dll
extension=php_imap.dll
extension=php_mysql.dll
extension=php_openssl.dll

Finally, create a file called ‘test.php’ inside the C:\lighttpd\htdocs folder that contains this one line:

<?php phpinfo(); ?>

Restart the web server using the Start Menu shortcut. See if it is still accessible locally (by going to http://127.0.0.1 in a browser) and externally (by going to http://{your ip} in a browser.) If you had to uncomment the server.port line in lighttpd.conf, your webserver will be located at http://127.0.0.1:81 locally, and http://{your ip}:81 externally. The rest of this tutorial will assume your server is running at http://127.0.0.1, so add the ‘:81’ as necessary if it applies to you. If the server isn’t working, check the line you added at the beginning of lighttpd.conf–are there smart quotes there instead of normal quotes? Did the file accidentally get renamed to lighttpd.conf.txt? Did you incorrectly specify the pathname with backslashes instead of forward slashes? Is your firewall off? Are you behind a router, and have to forward the port?

Once you’ve confirmed that the server is working, try navigating to http://127.0.0.1/test.php (the file you created before) in a web browser. If you see a purple table with ‘PHP Version 5.1.2’ at the top, PHP has been successfully installed. If not, go back and make sure you carefully followed all of Part 3b as exactly as possible. Once you’ve confirmed that PHP is working, delete the test.php file you created earlier.

Part 4c: Installing and configuring Perl

Find the Perl zip file you downloaded before, and extract it somewhere. Open the folder in Windows Explorer, and rename the top level directory (the one containing the ‘bin’ directory, and others) to simply, ‘perl’. Move the ENTIRE FOLDER (NOT the folder’s contents) to the C:\lighttpd directory. The path to perl.exe should now be C:\lighttpd\perl\bin\perl.exe. Stop LightTPD again. Open the file C:\lighttpd\etc\lighttpd.conf in a text editor, once again. Change the top line that we added before to this:

cgi.assign = ( ".php" => "c:/lighttpd/php/php-cgi.exe", ".pl"  => "c:/lighttpd/perl/bin/perl.exe", ".cgi" => "c:/lighttpd/perl/bin/perl.exe" )

Perl should work when you start LightTPD again.

Part 4d: Installing and configuring MySQL and phpMyAdmin

The easiest part of this entire operation is getting MySQL working. Extract the MySQL ZIP file you downloaded earlier, and rename the extracted top-level directory (the one containing the ‘bin’ and ‘data’ folders, among others,) to ‘mysql’. Move this folder into C:\lighttpd. Open the file C:\lighttpd\mysql\bin\mysqld-nt.exe. Congratulations, MySQL is now running in the background (it’s also a daemon.) Now, create a new file in the \bin folder called ‘admin.bat’. You should be able to right click on this file and hit ‘edit’, and it will automatically open up in Notepad. Paste this one line into Notepad, then save and close the file:

mysql -u root

This time, double-click on the admin.bat file. You should now be able to see a DOS terminal with some information about MySQL and a line at the bottom reading mysql> _. If you don’t see this, make sure mysqld-nt is running, and then try again. Type this into the terminal, where ‘your_password’ is any password of your choosing (don’t use any spaces:)

set password = password("your_password");

After hitting enter, MySQL should show this: Query OK, 0 rows affected. If it doesn’t, try choosing a different password, and making sure the entire line of code was correctly pasted into the terminal. Once you were able to set a MySQL password, try testing the database by typing ‘show databases;’ into the terminal. If you see a table with the ‘information_schema’, ‘mysql’, and ‘test’ databases listed, MySQL has been successfully configured; if not, read back over this section of the tutorial and make sure you followed all of the steps exactly.

You’re now ready to install phpMyAdmin. Decompress the phpMyAdmin ZIP file you downloaded earlier. Rename the extracted top-level directory (the one containing about 70 .php files) simply to ‘phpmyadmin’. Move this folder into your LightTPD htdocs folder, so that phpMyAdmin now resides at C:\lighttpd\htdocs\phpmyadmin. Make a new folder in the \phpmyadmin directory called ‘config’, so that you have an empty directory with the path C:\lighttpd\htdocs\phpmyadmin\config. Make sure LightTPD and MySQL are running, and then navigate to http://localhost/phpmyadmin/scripts/setup.php in a web browser.

In the ‘servers’ section, click the ‘Add’ button. The first field you’ll need to change is the ‘Authentication type’ field. Change it to ‘cookie’. Type the same password you set for your MySQL root account before in the ‘Password for config auth’ field. You can type a name for your server in the ‘Verbose name of this server’ field–call it whatever you want to. Type ‘root’ in the ‘phpMyAdmin control user’ field and the same password you set for your MySQL root account in the ‘phpMyAdmin control user password’ field. Finally, type ‘phpmyadmin’ in the ‘phpMyAdmin database for advanced features’ field. Click the ‘Add’ button with the green text. In the ‘Configuration’ section (the third grey rectangle from the top,) click the ‘Save’ button (if this button is unclickable, you forgot to make the ‘config’ directory–please see above.)

Open the ‘config’ directory you made before in Windows Explorer. There should be a file called config.inc.php in it. Move this file up one directory (into \phpmyadmin) so that the path to it is C:\lighttpd\htdocs\phpmyadmin\config.inc.php. Delete the now empty ‘config’ directory you created before, and navigate to http://localhost/phpmyadmin in a web browser. Log in with username ‘root’ and your MySQL password. Congratulations–you’ve configured MySQL and phpMyAdmin. That wasn’t too painful, was it?

Part 5: All the Small Things

Even though all of your software is installed and [hopefully] working, there are several things you might consider doing to make everything work even more seamlessly, such as:

  • Automatically running LightTPD and MySQL on system startup. You may want to either start up LightTPD, or both LightTPD and MySQL automatically when Windows loads, rather than turning on the programs every time you want the web server to load. To do this, I used Windows Task Scheduler. Open Task Scheduler by clicking on Start → All Programs → Accessories → System Tools → Scheduled Tasks. Double-click on ‘Add Scheduled Task’. Hit Next, then click ‘Browse…’. Locate the shortcut to start LightTPD in c:\lighttpd and select it. Under ‘Perform this task:’, select ‘When my computer starts.’, then hit Next. Enter your Windows password in the password boxes if you have one, hit Next, check the ‘Advanced Properties’ checkbox, and then click ‘Finish’. To guarantee that your server program won’t shut down by itself if it is idle, make sure that all of the checkboxes on the “Settings” tab of the window that pops up are unchecked. If you want to run MySQL on boot as well, repeat this process, but instead of using the LightTPD shortcut use C:\lighttpd\mysql\bin\mysqld-nt.exe.

  • Setting up a dynamic domain name redirect for yourself at no-ip.com. If you were one of the people whose ISP was blocking traffic on port 80 and you don’t fancy typing ‘:81’ all of the time, if you have a dynamic IP (it changes periodically,) or if you don’t like typing IPs in general, you can get a free [sub]domain name from No-IP that will redirect to whatever IP and port you specify.

  • Setting up a very simple FTP server. If you’re not at your computer, you probably want to mess around with the files on your server using FTP, like you’re used to, right? There are probably several dozen free FTP servers for Windows available, but for the absolute beginner, nothing could be easier to use than Pablo Van Der Meer’s Quick ‘n Easy FTP Server Lite. Download the program from his web site (get the ‘lite’ version,) unzip it, make sure all of the extracted files are in a directory (call it ‘FTP’ for example.) Move this directory into C:\lighttpd so that the extracted files reside at C:\lighttpd\ftp. Next, open FTPserver.exe and click the ‘I agree’ button. Create an account for your server by following the onscreen prompts. Do NOT check the ‘Create an anonymous account’ checkbox when it appears. When the prompt asks you to specify a home directory, set it to C:\lighttpd\htdocs. When asked what permissions the account should have, check all of the checkboxes. After clicking ‘Finish’, click the green ‘Start’ button at the top left hand corner of the screen. That’s it. An FTP server should be running on TCP port 21, and again, if you’re behind a firewall or router you’ll have to forward and/or unblock port 21 accordingly. If your ISP blocks traffic on port 21, you can change the listening port as well as other things by clicking on ‘View’ and then on ‘Configuration’. It should be noted that there is an option in the configuration window to start the FTP server automatically when the computer starts.

Part 6: The Summit

That’s it! You’ve successfully installed and configured the LightTPD web server with support for PHP and MySQL (with phpMyAdmin as a frontend.) The only other thing you need to know is that whenever you make configuration changes (especially to php.ini or lighttpd.conf), a good practice is to make sure that LightTPD is stopped before you edit the files, and then to restart the server after you edit them (you shouldn’t have to stop and restart MySQL.) This might save you headaches down the road. In any case, though, you did it. Pat yourself on the back. Or try to applaud yourself with one hand. Whatever works for you.


Note that as the author of this tutorial, I don’t guarantee that your configured servers are part of a 100% secure setup–this tutorial was written mostly for individuals who want to run a development or personal web server or who want to tinker with PHP, and was not meant to be a guide to setting up a production web server. It therefore should come to you as no surprise that I will not be held responsible or liable for any loss of data, money, or computer function as a result of following this tutorial.


Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.