Install WordPress on WLMP (Windows, Lighttpd, MySQL and PHP)

Install WordPress with WLMPWordPress blog designers and plugin developers work with remote files on a daily basis. The problem is, accessing files on your server, which is probably hosted hundreds of miles away from your geographic location may involve quite a lot of delay. Moreover, you may have to stop working if you have connectivity problems.

Fortunately there are more convenient approaches to this. Existing solutions are sub-optimal because it uses WAMP (Windows, Apache, MySQL, and PHP).

Why WLMP? An Overview

Don’t get me wrong, Apache is well-established and most widely used server software throughout the Internet. It is able to handle almost any load and setup, but at the same time the cost in terms of memory consumption and processing cycle are also huge.

Lighttpd is a better alternative for this reason. For WordPress hosting, it has more than enough features to support all the necessary operations. Tests upon tests show that the performance in lightty is significantly better even with limited resources.

This is an extra bonus, especially for people who have scarce resources on their workstation — which is most likely the case.

Note: Albeit using the same name, this setup is independent from the WLMP project, except that the lighttpd software package is taken from the project. Other than that, we are going to install and slightly optimize MySQL and PHP separately.

System Requirements

For this tutorial, I’m going to use Windows Vista. There is no specific requirement as far as I know of. This setup has also been tested in Windows XP Service Pack 2.

The installation process is pretty simple. When starting the various servers, they may consume less memory and as they serve more data and pages, they will need more memory.

mysqld, for instance, requires only a bit more than 1MB when you start it for the first time. The php-cgi occupies around 5MB at first.

However, after running WordPress for some time…

  • LightTPD still occupies only less than 1.5MB. You’re going to like this, aren’t you?
  • PHP running in FastCGI is about 6.5MB.
  • MySQLd takes around 11MB.

The total memory consumption is ~ 19MB. Of course, that depends on how you optimize MySQL or how much data do you have in the database. The point is, you probably have known about PHP and MySQL, but isn’t the figure for LightTPD encouraging?

WLMP Memory Consumption

Compare this to Apache. Memory consumption of 50 – 300MB per process is not unheard of, and in fact it is quite common. Note that I’m not comparing apple to apple, but you don’t need the extra features in Apache. Another thing worth considering is CPU load.

In short, life with WLMP is much lightier, better, and faster.

Get Started with WLMP Installation

Lighttpd LogoI presume that the “W” part, which is Windows, is already done. Unless you are viewing this page through another computer, chances are you have already had a Windows installation on your desktop computer or laptop.

So let’s go ahead and proceed with lighty. Download a copy of the newest version of lighttpd from WLMP project web site. For demonstration purpose, the version I’m using is 1.4.20, but it should work with other versions as well.

Installation Screen for LightTPD

Installation of lighttpd is straightforward. You only need to choose the directory to install the software and proceed. In this case, C:\Program Files\Lighttpd is fine.

Configuring and Running Lighttpd

The lighttpd installation includes a script that allows you to test and make sure that your installation is working fine before configuring the server.

This can be done simply by running the TestMode.bat, found in your lighty installation directory. When you double-click it, a command prompt window will appear. Don’t press Ctrl+C yet. If you see it, that means lighttpd is currently running.

In fact, the server may display message such as the following:

yyyy-mm-dd hh:mm:ss: (log.c.97) server started

Note: If you are running Windows Firewall, a dialog may appear, warning you that lighttpd is trying to accept incoming network connections. It is important that you press the Unblock button to make exception to the http port (port 80) for lighty only if you want to allow remote connections. Otherwise, keeping it blocked still allows you to access from your desktop.

This dialog box will only be displayed once so you don’t have to keep allowing the connection each time you start the server.

Unblocking LightTPD in Windows Firewall

In case you are wondering, the exception added to Windows Firewall is named A fast, secure and flexible webserver, NOT LightTPD.

The next step is to fire up a browser and type in:

http://localhost

in the address bar of your browser. A screen similar to the following should appear right before you.

Test Page for LightTPD

This page also tells you what to do. For instance, you may put your web site in C:\Program Files\Lighttpd\htdocs. You will do that later when installing WordPress.

You may also make changes to configuration file, which is C:\Program Files\Lighttpd\conf\lighttpd-inc.conf. This file also includes other files in the same directory if you enable that.

Now that you have it running properly, go to the command prompt window and press Ctrl+C to stop lighttpd.

A message will show about the status of the shutdown process. You may need to press any key after that to get rid of the window.

Configuring Lighttpd to Interact with PHP

In short, Lighttpd is able to run PHP-based files via one of these two methods:

  1. Running PHP as CGI (Common Gateway Interface). This requires the CGI module (mod_cgi). Whenever a request for .php file is being made, lighty will invoke an instance of php-cgi.exe and let it process the script before returning the result.
  2. Running PHP in FastCGI mode. As the name implies this method is faster because a predetermined amount of children processes have been invoked and run in the background. Lighty interacts with PHP’s FastCGI by using hostname:port pair (TCP protocol) or via the UNIX sockets or named pipes. This requires the mod_fastcgi module.

I personally prefer the FastCGI method mainly because it is more flexible. For instance, if I happen to have a desktop and laptop on the same local network, I could install the PHP running in FastCGI mode on my laptop. The lighty and MySQL could just reside on the desktop.

It certainly make it even lighter

Up until now, we haven’t installed PHP yet, but there are several things you should do to make lighttpd ready to send queries for PHP files to FastCGI.

You need to open the file in C:\Program Files\Lighttpd\conf\lighttpd-inc.conf, then do the following:

  1. Activate the mod_fastcgi module by deleting the hash sign (‘#’) at the beginning of the line.
  2. Change the server.document-root variable to “c:/program files/lighttpd/htdocs” instead of just “htdocs/”. This is necessary to make FastCGI work flawlessly. You may need to scroll down a bit to find this configuration line.
  3. Finally, scroll down again to the fastcgi module section and change the fastcgi.server configuration block to read like below.
fastcgi.server = ( ".php" =>
                   ( "localhost" =>
                     (
                       "host" => "127.0.0.1",
                       "port" => 10000,
                       "broken-scriptfilename" => "enable"
                      )
                    )
                  )

In previous section, you have tested lighttpd, and you are seeing the error messages right on the command prompt window (console). The console, in this case, is the error log destination.

When running as a server on the background, you wouldn’t be able to see the console so the error messages should be directed to a file. The same thing applies to the http access file.

You only need to add two lines to make this happen:

accesslog.filename = "c:/program files/lighttpd/logs/access.log"
server.errorlog = "c:/program files/lighttpd/logs/error.log"

Also make sure the upload directory is set to full path…

server.upload-dirs = "c:/program files/lighttpd/TMP"

Running and Stopping Lighttpd, MySQL and PHP FastCGI with Batch File

The Windows installation of lighttpd includes programs to install and remove lighttpd as Windows service but for one reason or another it is not working.

Anyway, I still prefer the batch script executable though because I could start and stop all lighty, mysqld and php-cgi at the same time.

Here is the content for start-lighttpd.bat:

1
2
3
4
5
6
7
8
9
@ECHO OFF
ECHO Starting PHP FastCGI...
RunHiddenConsole.exe C:\Program Files\PHP\php-cgi.exe -b 127.0.0.1:10000
ECHO Starting LightTPD...
lighttpd.exe -f conf\lighttpd-inc.conf -m lib
ECHO Starting MySQL...
RunHiddenConsole.exe "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini"
SLEEP 1
EXIT

Copy and paste the text above and save it as start-lighttpd.bat in C:\Program Files\LightTPD. Alternatively download start-lighttpd.bat here.

The script to stop lighttpd, mysqld and php-cgi is properly named stop-lighttpd.bat. The content is as follow:

1
2
3
4
5
6
7
8
9
@ECHO OFF
ECHO Stopping MySQL...
bin\process.exe -k mysqld-nt.exe >nul
ECHO Stopping LightTPD...
bin\process.exe -k lighttpd.exe >nul
ECHO Stopping PHP FastCGI...
bin\process.exe -k php-cgi.exe >nul
SLEEP 1
EXIT

Again copy, paste and save to the text above or download stop-lighttpd.bat here.

With both this script, you can run and stop lighttpd, mysqld and php-cgi as you wish. Turn it on when you are working and remove them to gain more memory afterwards.

Don’t run the batch file yet. You need to install PHP and MySQL first… which the following steps are exactly about.

Installing PHP on Windows

PHP LogoPHP installation is pretty simple. Just go to PHP download page and download PHP x.x.x installer. The PHP version used for this demonstration is 5.2.6.

Run the installer executable program, and choose Other CGI when asked for the type of server you will be running. As we are going to run PHP independently in FastCGI mode, that is the option you should choose.

Install PHP as Other CGI

You should seriously consider adding PHP path to your system PATH variable so you can enter php or php-cgi command from any directory in the command prompt to run PHP.

While you can choose the whole extensions, I recommend against it. You can always run the installation package again to add extensions later as you need them.

For now, here are the list of PHP extensions you should seriously consider:

  • Curl
  • GD2
  • MySQL

Recommended PHP Extensions

Then proceed with the installation. By default PHP will be installed in C:\Program Files\PHP.

Running PHP in FastCGI Mode Under Windows

Some people use third party program, such as Spawn-CGI.exe from lighttpd package, but I can’t seem to get it running. However, it is not necessary either.

php-cgi.exe now runs well in FastCGI mode without any third party software. Open a command prompt window and run php-cgi -h to see full options.

Making php-cgi to listen to a <host>:<port> pair is easy. The following command will do it.

php-cgi -b 127.0.0.1:10000

The line instructs php-cgi to bind to localhost, which has an IP of 127.0.0.1 — it is inaccessible outside of your machine — and on port 10,000. This has to match the lighttpd configuration above.

Now it is much more convenient if you are able to run this without opening a command prompt, isn’t it? Here is a solution.

If you want to get rid of the command prompt window when php-cgi is running, you should download RunHiddenConsole.zip and unzip the executable file in C:\Program Files\LightTPD. This program will execute php-cgi, run it in the background but hide the command prompt window so it doesn’t clutter your desktop. (You will use it twice to run php-cgi and mysqld — the latter if you choose not to run it via Windows service).

Installing MySQL on Windows

MySQL LogoMySQL is the database engine used by WordPress and countless other database-powered applications. That sounds more complex than the above two programs, but really it is the most simple to install of all.

All you have to do is answer questions and choose the right options. This is unlike Lighttpd and PHP installations above.

Now you can relax… all the hard work has been done so far.

First off, you need to download a version of MySQL for Windows. If you’ve never installed this before, the easiest way is to download a package with executable setup file.

For demonstration purpose, it would be Windows Essential (x86).

Save to your desktop and run it once download is finished. Let’s go through the entire installation process step by step.

First, pick Typical installation option.

Install MySQL with Typical Option

This will install the MySQL server and client programs but not the C include files. You don’t need them unless you are developing an application that uses MySQL as the database backend.

Once the files are installed, you will be prompted to Configure the MySQL Server now. Let the checkbox checked before proceeding to the next step.

Configure MySQL Upon Installation on Windows

The next screen allows you to choose between Detailed Configuration or Standard Configuration. Pick the former, just for the sake of curiosity about what options are available to us. Don’t worry, if you don’t know what an option is, you can always leave it as is.

Detailed MySQL Configuration

When asked to choose the server type, the choice in this example is obvious. This setup is for experimenting with various WordPress themes and plugins, so low memory consumption is preferable. Choose Developer Machine. The other option will allow more concurrent connections running at the same time, which wastes more memory.

It doesn’t matter which one do you choose in the next step, but in this case, the choice is Multifunctional Database.

Multifunctional Database Option in MySQL

Following the option above, you will see a screen that prompts you for InnoDB Tablespace Settings. Choose the directory where you want the file to be placed.

MySQLl Tablespace Settings

The next step shows a screen where you can customize the number of concurrent connections allowed by MySQL. Although it is safe to choose Manual Setting and set it to 15 or even lower, I leave this to 20.

MySQL Decision Support

MySQL is capable of accepting connections through named pipes or TCP/IP networking. This is a more common setup, and more flexible too as you may migrate the MySQL server to another machine and still connect over the network, so leave all the settings as is. Enable TCP/IP Networking and Enable Strict Mode and leave Port Number: 3306 as the standard port.

Because you don’t need to make this MySQL database server to serve data outside of your own desktop computer, it is not necessary to add exception to the Windows Firewall for this port. While running the batch file later, if Windows asks you if you want to unblock this, feel free to choose Keep Blocking, unless you want to allow remote connections.

MySQL TCP/IP and Strict Mode

Next, you may set the character set for this database server. For English and other West European language, the Standard Character Set option is good to go.

MySQL Charset

You may want to Install As Windows Service. The Launch the MySQL Server automatically allows you to run MySQL as you start Windows.

This is certainly an option, although you could also run it along with the batch file above so you have the capability to start and stop it on demand from one place. Starting and stopping Windows service is not hard, but it needs more clicks separately.

Include Bin Directory in Windows PATH is a good idea so you can run mysql from any command line.

MySQL as Service and Add to PATH

It is recommended that you enter the root password so access to the data is protected. You will need this to manage MySQL data. If you don’t need other people from remote machines access this database server, leave the Enable root access from remote machines option unchecked.

MySQL Security Settings

That’s it. Now you have installed LMP on your Windows system.

Check to Make Sure WLMP Runs as It Should

Now you can run start-lighttpd.bat by double-clicking on the batch file. It first starts php-cgi, binds to the loopback interface (localhost, IP 127.0.0.1). Next it runs lighttpd, followed by mysqld.

Check in Windows Task Manager to see if you have LightTPD.exe, mysqld-nt.exe and php-cgi.exe on the list. Sort by Image Name first to make it easy to locate program names.

If you see them all, fire up command prompt and issue the following command:

netstat -ban -p tcp

Basically, it tells netstat to:

  • -b: displays the executable involved in creating each connection or listening port.
  • -a: displays all connections and listening ports.
  • -n: displays address and port numbers in numerical form.
  • -p tcp: shows connections for TCP protocol only.

Among the result you should see the following:

  • Port 80 – System. For one reason or another it doesn’t shows as lighttpd.exe, but you can confirm it as such.
  • Port 3306 is occupied by mysqld-nt.exe, which is exactly the MySQL server you were starting just now.
  • Port 10000 – php-cgi.exe. Instead of 0.0.0.0 (all IP address in the system, this is specific only to loopback address (127.0.0.1). The PHP is now running in FastCGI mode, ready to accept connection.

For a full test you need something that access the web server, calling PHP script and connect to MySQL database.

Because WordPress does exactly this, let’s proceed by installing it on WLMP.

Installing WordPress on WLMP System

WordPress installation should be easy by now with everything already in place. First of all, you need to prepare a database for WordPress.

You may choose to install PhpMyAdmin for MySQL database management but for simplicity let’s just dive into MySQL’s command line interface.

  1. Open a Command Prompt.
  2. If you enable MySQL in the PATH, you should be able to type in mysql -u root -p directly and get a password prompt. Enter the password you’ve set earlier when you install MySQL.
  3. At the MySQL command line interface, create the database and grant access to a specific user. It is recommended that you always create a user who has access only to one working database for security reason.

create database wp;
grant all on wp.* to 'wpuser'@'localhost' identified by 'yourpass';

The first command create the database wp. The second command grant all privileges to the user wpuser connected via localhost with the password yourpass. Of course, change your password — or any other options — as necessary.

Use the exit command to get out of the MySQL command line interface, in case you don’t know how to do it.

You’re set!

Now download and unpack the newest version of WordPress. Put the files in C:\Program files\LightTPD\htdocs. Rename the directory if you so choose. Put all the files inside the wordpress directory in root if you want the blog to be installed on the root directory.

Now open a browser window and access the files. If you put the wordpress directory in the document root and rename it to blog, type the following into the browser’s address bar:

http://localhost/blog/

A screen like the following appears:

Create WordPress Configuration wp-config.php

See, you don’t even have to copy the wp-config-sample.php to wp-config.php and edit the content to reflect your database configuration. WordPress will prompt you with the information with this wizard.

The next screen should be obvious. Please read if you are not familiar with WordPress installation. When finished, proceed to the next step, which is a screen where you could enter your database information.

WordPress Database Configuration

WordPress will test the database connection and if all is going fine, you will be prompted once again to run install.

The famous installation process involves entering your blog title and email address. That’s it!

Upon successful installation, you will see a success screen with your user name and password.

Important: Because most likely you don’t have a mail service in your desktop, you won’t get new blog creation message along with the admin’s username and password. Make sure that you jot down the details before you close the window or hit the Login button.

Try to login with the provided user name and password, and immediately change the password to something memorable. It doesn’t have to be secure because only you are able to access it.

If you’ve successfully reached this far, and you see the WordPress Dashboard after logging in, you can be sure everything is working well. Congratulations.

Now go play around with your newly installed WLMP and WordPress!

Return to How to Make a Server — Building High Performance Server.

Return to Blog Tips for a Better Blog — Blog Building University.


Blog Building University features tips, techniques and strategies on starting and growing your moneymaking / business blog. Subscribe to get fresh content delivered to you daily!

Blog Building University Full Content Feed

Comments

2 Responses to “Install WordPress on WLMP (Windows, Lighttpd, MySQL and PHP)”

Blogging is Web Publishing 2.0.
BlogBuildingU.com solves your web publishing puzzles, one piece at a time.