|
Mobile - Web - Media
Tuesday, Sep 11, 2007 6:44:17 PM
Running LightTPD and PHP on Windows
While I honestly feel ColdFusion is a great platform for Web Applications, it turns out there's some things it's not so great at, one of which is serving of a lot of files, and in my case, it's the streaming and downloading of mp3s. ColdFusion has a max thread count setting, and if you are serving an mp3 file via CFContent (to hide the file's location, and handle tracking it's use), this max number becomes a serious limitation.
This has now become a problem because ArtistServer is seeing more traffic and more listeners, which means more streaming and downloads. We've started hitting that max thread count, and need to move the mp3 streaming and downloading to another solution. My goals for the new solution include:
- High availability – Able to support a large number of simultaneous users
- Free – I can't afford to purchase solutions, and I'd like to move more into open source solutions
- Stable – While I am looking for mature solutions, I will try newer options if they look promising, but they need to be stable
- Focus on serving files – If possible, the soltuions will need to be ideal for serving files and supporting byte ranges (ffwd an mp3)
- Can Run on Windows – I'd like to move to linux, but I'm hesitant to change everything at once.
After some research, I decided to try a relatively new Web server called LightTPD and PHP, a Web standard. For the OS, I'll use Windows 2000 Advanced Server. The process takes a few steps, so I thought I'd outline them and post the process so that other's can save time and use this as reference.
From the lighttpd Web site: http://www.lighttpd.net/
lighttpd is used by many well-known sites. The typical scenario is using lighttpd as off-load server to push out static content and leave to complex work to another server. One example is YouTube. They have a farm of servers which push out the thumbnails you see before you see the movies.
Security, speed, compliance, and flexibility--all of these describe LightTPD which is rapidly redefining efficiency of a webserver; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) LightTPD is the perfect solution for every server that is suffering load problems. And best of all it's Open Source licensed under the revised BSD license.
light footprint + httpd = LightTPD (pronounced lighty)
For my specific case, I now have a test server setup with lighttPD and PHP, and have started working on a translation of my file serving/streaming/tracking code. Once I have the code up and running, I can start testing on linux server and consider removing Windows from the equation. Making a platform change would provide even better performance and a higher number of concurrent users. Why not do it now? Because I'm new to PHP and don't want to change all the elements at once. After I gain a comfort level with PHP, I can start working with it on linux. Windows + LightTPD + PHP
- Install Windows Server: I'm using Win2000 Adv Server. Remove all the items from the installer that you won't need on a server, like games, etc. Uncheck everything that deals with IIS, the mail server, and ftp. I suggest using other options for FTP. I don't know of a mail server to use, so if you must, install Microsoft's mail server.
Once Windows is installed, run Windows update and reboot accordingly. Do this until you finally do not see any more updates. With Win2000 Server, I had to upadate 'Windows Update' then do a few updates, then about 54 updates, then another 9, then a few more... so it takes awhile.
- Download: Now download all the software you'll need to run the server. In my case, this will include:
- Install: VNC Server – for remote access, Notepad++ for editing config files, and FileZilla as your FTP server
- Install LightTPD: I suggest installing to the root: C:\lighttpd
- Install PHP: I suggest installing to the root: C:\PHP - during installation, you will be asked to select your server, select 'other CGI' as 'lighttpd' is not a listed option.
- LigHTTPd Configuration – I'm using version: 1.4.18
- Open the configuration file: C:\LightTPD\conf\lighttpd-inc.conf
- Uncomment mod-cgi – just delete the '#' in front of it.
- Uncomment mod-rewrite - same method, unless you don't need it
- edit "index-file.names" leaving only: "index.php", "index.htm"
- consider trimming the mimetypes down to what you would be serving
- edit "static-file.exclude-extensions" - set to ".php" only
- be sure to create a file for catching errors – uncomment this line after you create the file and save it at the root.:
server.error-handler-404 = "/error-handler.php"
- Uncomment cgi.assign, delete all but php, and add a slash:
(".php" => "PHP/php-cgi.exe") to this: (".php" => "/PHP/php-cgi.exe")
- Set LighTTPD up as a service – first, click on this exe file: C:\LightTPD\bin\Service-Install.exe
When I tried this, the registry entries fail, so the next step is to edit the registry and add the keys by hand (or a .reg file). Be sure to replace the lighttpd installation directory with your own. Save the following as a .reg file and double click on it to merge these keys with your registry (if the service installer did not show an error, skip this step):
Windows Registry Editor Version 5.00
[HKEY_Local_Machine\SYSTEM\CurrentControlSet\Services\LightTPD]
"DisplayName"="LightTPD"
"Description"="A fast, secure and flexible webserver - WLMP Project"
"ObjectName"="LocalSystem"
[HKEY_Local_Machine\SYSTEM\CurrentControlSet\Services\LightTPD\Parameters]
"AppDirectory"="C:\\LightTPD"
"Application"="lighttpd.exe"
"AppParameters"="-f conf\\lighttpd-srv.conf -m lib -D"
[HKEY_Local_Machine\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List]
"C:\\LighTTPD\\lighttpd.exe"="C:\\LightTPD\\lighttpd.exe:*:Enabled:LightTPD (WLMP Project)"
- At this point, you may need to stop/start the lighttpd server service – I use the Computer Management Console – and navigate to the Services icon, then the actual service.
- In your browser's address bar, type: localhost – you should now see the default index page for lightTPD. If not, possibly the registry keys were not added correctly, or you made a mistake when editing the lightTPD configuration file.
- PHP Configuration – I'm using version: 5.2.4
- open the php.ini file: C:\php\php.ini
- move the upload temp and session directories, and changed their references in the php.ini file:
upload_tmp_dir="C:\php\upload"
session.save_path="C:\php\session"
- locate and set: doc_root ="C:\lighttpd\htdocs"
- Test the server
- create a new text file in the web root called index.php
- type this into it:
then save
- in your browser's address bar, type: localhost
- you should see the php info specs in your browser
- Alternate Setup: Unfortunately, fastCGI on Windows either doesn't work, or doesn't work very well (at this point in time), which means it won't work with lightTPD. There are many other options for you to tweak and try in the configuration file, my only suggestion is to save a copy of this first version of your configuration file as a backup.
- Finish:
This information is offered for free and does not imply any responsibility nor consultation. If you have any questions, I'll do my best to answer, but I think the best thing to do is to post to the lighttpd forums.
Good luck in your developments, I'll post again once I have made some progress.
ColdFusion
lighttpd
PHP
Windows
- ADD TO:
-
Blink
-
Del.icio.us
-
Digg
-
Furl
-
Google
-
Simpy
-
Spurl
-
Y! MyWeb
|
 |