| Lighttpd and Joomla - A How To |
| Written by ircmaxell | |
| Sunday, 29 April 2007 | |
|
If you read my other article about Lighttpd, you may be wondering how to set up a server to use Lighttpd instead of Apache. There are really two ways to set Lighttpd up. You can use is as a proxy to Apache (and let apache deal with dynamic pages), or use PHP as FastCGI, which is just as fast, and even more reliable. To see what a difference Lighttpd made check this out... The spikes are the maximum amount of page views with my server running at its resouce limit!
![]()
When you look at that graph, you may be wondering what that is. That graph is pulled from Alexa's Page Views tab. I can tell you that during every spike you see, my server was running at its limit, and could not handle any more traffic. Also, the only change I made in March, was switching over to Lighttpd. Still interested? Read on... Installing LighttpdNo matter how you want to set Lighttpd up (as a proxy, or with FastCGI), you need to install Lighttpd first. To make life easier, I have found that you need to use LUA to allow for SEF URL's when using FastCGI, so lets just install it anyway. The first step is downloading the source for LUA from http://www.lua.org. Then install the latest version of LUA using ./configure, make, and make install. Once LUA is installed, locate the path to lua.pc. Now, download Lighttpd from http://www.lighttpd.net. Extract Lighttpd, and go into the extracted directory. There, run the following commands (replace path/to/lua with he path to lua.pc WITHOUT the file name):
That's it. Lighttpd is now installed on your machine. Before we can start it, we need to set up a configuration file. ConfigurationOk, locate the default configuration file for Lighttpd (on my install, lighttpd.conf was located in /etc/lighttpd). Here are my recommended settings (where changes should be made): server.modules = ( url.rewrite-once = ( "^(.*)mosConfig_(.*)$" => "/403.php", evhost.path-pattern = "/home/www/%0/public_html/" -- (this will make the home directory for www.test.com to /home/www/test.com/public_html... You can symlink that to your real directory) Lighttpd as a ProxyAdd these lines to your config (substituting for your domain name) $HTTP["host"] =~ "myhost\.com" { The only change you'll really need to make to Apache is changing the port it runs on. Change the port number to 8080. Restart Apache, then start up Lighttpd. That's all you need to do! From then on, Lighttpd will be running your front end, with Apache running the back end. Lighttpd Standalone!Well, from here on out, you need to do a few more things. The first thing you need to do is download PHP and install PHP as FastCGI. For more information about installing PHP for Lighttpd, check out this article. Once PHP is installed, add these lines to allow for SEF URL's. Add these lines to your config (substituting for your domain name) $HTTP["host"] =~ "engineeringonline\.org" { Now, you need to make a file called joomla.lua in that directory. Basically, this file will do what .htaccess does for Apache with modRewrite. Here's what you want your joomla.lua file to look like: if (not lighty.stat(lighty.env["physical.path"])) then A word on performanceRight out of the box, Lighttpd blew Apache away in terms of throughput. The problem with it is that it uses a LOT of CPU power. Durring the past high traffic event, my server was averaging around 50 hits/second while using 100% of dual - dual core Xeons. Then I came across two directives, server.event-handler and server.network-backend. You will have to set these based on your OS, as seen here , but what a difference. Once I restarted Lighttpd, I saw average traffic jump to over 125 hits/second, with a CPU time of 25% and under. What a difference! The switch to Lighttpd can be a lot of work, and a headache at times, but it's WELL worth it for speed and performance! Trackback(0)
Comments (8)
![]() written by waleed gadelkareem, November 07, 2007
I wonder why you're using lua instead of
server.error-handler-404 = "/index.php" it doesn't let lighty send any 404 headers to browser either Question about the port number.. .
written by linuxpenguin, May 02, 2007
I hate to ask. . . but is there anything magical about port 8080 that I can't use another port?
For the testing, I set up lighttpd to use port 81 and kept Apache at port 80. (I was testing it by connecting through the LAN by typing in "http://192.168.0.120:81"* in Firefox.) My impression is that this should work, at least for local PCs until I'm done testing and ready to switch my whole site to lighttpd. *That's not my server's actual IP, I just made one up for an example. ... written by linuxpenguin, May 02, 2007
I am trying to do the proxy but, for example when I go to my PHP pages, I'm getting a download dialog! Any ideas?
Write comment
|
|
| Last Updated ( Sunday, 29 April 2007 ) |
| < Prev | Next > |
|---|













Anyhow, I am testing lighttpd on my servers with Joomla but I get a problem with the server's session.save_path when I am trying to install Joomla. I tried 4-5 solutions that I found but still, I get the error