Wednesday February 09, 2005
UPDATE: Lighttpd 1.3.11 has been released, which includes my patch for osx, I’ve updated this post to reflect this, since the patching step is no longer needed.
There’s been a lot of buzz in the Ruby on Rails community lately about lighttpd which claims to be a lightweight, secure and a friggin’ fast http server. And guess what? It most certainly is!
Below are my notes of getting lighttpd 1.3.10 up and running on Mac OSX 10.3 with mod_mysql_vhost and mod_fastcgi. Please note that the patch and symlinking of libmysql may or may not be needed in future versions of lighttpd. Also note that the MySQL version used below is based on the ServerLogistics Complete MySQL package, if you’re using a different package or your own the paths may be different, do a locate mysql_config
to figure out where it is.
First of all we need the FastCGI developer kit:
curl -O http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
sudo make install
We also need the pcre libraries:
(cd ..)
curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-5.0.tar.gz
tar xzvf pcre-5.0.tar.gz
cd pcre-5.0
./configure
make
sudo make install
Then, we need to download and unpack the lighttpd tarball:
(cd ..)
curl -O http://www.lighttpd.net/download/lighttpd-1.3.11.tar.gz
tar -xzvf lighttpd-1.3.11.tar.gz
cd lighttpd-1.3.11/
I wanted to be able to use the mod_mysql_vhost and since I’m using the ServerLogistics MySQL package, installed in /Library/MySQL/
a bit of manual tinkering was requirred. The easiest was to create a symlink for the header files to /usr/local/include/mysql
:
sudo ln -s /Library/MySQL/include/mysql /usr/local/include/mysql
Note: This probably isn’t really the optimal solution, but I didn’t really feel like poking around too much in the sources to correct the path problem
Next we need to run the configure script, telling it we want to use mysql for the vhosts:
./configure --with-mysql=/Library/MySQL/bin/mysql_config
If all is good you should see something like this once the configure script is done:
Plugins:
mod_rewrite : enabled
mod_redirect : enabled
mod_ssi : enabled
mod_cgi : enabled
mod_fastcgi : enabled
mod_proxy : enabled
mod_evhost : enabled
mod_simple_vhost: enabled
mod_mysql_vhost : enabled
mod_access : enabled
mod_alias : enabled
mod_setenv : enabled
mod_usertrack : enabled
mod_compress : enabled
mod_auth : enabled
mod_status : enabled
mod_accesslog : enabled
mod_rrdtool : enabled
mod_secdownload : enabled
mod_expire : enabled
And finally we compile and install the binaries:
make
sudo make install
Hooray! We’ve successfully installed lighttpd, now we just need to take care of the config and log files and we’re good to go, start by copying the lighttpd.conf to /etc (I think that’s a good place to have it, you may disagree)
sudo cp doc/lighttpd.conf /etc/lighttpd.conf
Configuring the lighttpd.conf should be a breeze, it’s fairly self explanatory, also, please consult the documention
Now create and set the proper permissions on our two log files:
sudo touch /var/log/lighttpd.error.log
sudo chmod 666 /var/log/lighttpd.error.log
sudo touch /var/log/lighttpd.access.log
sudo chmod 666 /var/log/lighttpd.access.log
Finally, we can start the lighttpd webserver and start having some fun with it:
sudo lighttpd -f /etc/lighttpd.conf
You may wish to add the -D
flag so it’ll keep running in the console, instead of as a daemon, to make it easier to shut down while you’re testing your config and such.
That’s it! You’re all set to go, using mysql based vhosts is fairly straingforward, just take a look at the documentation example to get an idea how to set it up.
If one where to speculate freely one could imagine that we set ourselves up a complete environment for developing Rails projects, using Rails. Perhaps I’ll even write an article about that in the future, until then; enjoy your lighttpd!
Feb 16 at 13:20
OSX from 10.3 onwards has kqueue which should give a performance boost, just add the line below to the config file to use it:
<br /> server.event-handler = "freebsd-kqueue"<br />
Feb 16 at 13:50
Great article, waited for something like this for ages :-).
One little error, you put:
cd pcre-5.0.tar.gz
When I belive it should just be:
cd pcre-5.0
Feb 16 at 13:58
Oliver: ah yes, a silly typo/mindslip :)
David: Cool, didn’t know that panther had kqueue..
Feb 16 at 16:35
Test my Lighttpd Darwinports set up, please!
There has been a lot of buzz lately in the Rails community about lighttpd. I’ve decided to check out this buzz, and being recently acquainted with Darwinports, I decided to write up a portfile for it.
IR
Feb 18 at 22:59
[…] up against a maddening error during make that I couldn’t fix until I came upon this excellent tutorial by Johan on installing on OS X. He found the same e […]
Feb 19 at 00:44
[…] up against a maddening error during make that I couldn’t fix until I came upon this excellent tutorial by Johan on installing on OS X. He found the same e […]
Feb 19 at 06:45
A little shortcut:
curl http://fastcgi.com/dist/fcgi.tar.gz | tar xfz -
cd lighttpd-1.3.10/
Feb 20 at 05:21
[…] authentication, compression, etc). Since I had to build that from source (many thanks to The Exciter for documenting the build on OSX and providing a path to g […]
Feb 25 at 01:58
[…] ot too exciting musings about technology
« Installing Lighttpd on OSX Posted on Friday, February […]
Feb 28 at 15:07
If you’ve left out the patch needed for v. 1.3.10 wouldn’t it be an idea to change the download links to fetch v. 1.3.11 instead of the old version?
Feb 28 at 15:30
indeed.. Or maybe I should just leave that as an exercise to the reader ;)
Feb 28 at 16:42
You could. It would create a lot of comments to this post :)
Im running into another problem here. When I try to configure lighttpd almost everything looks good. Except the first three lines:
mod_rewrite : disabled (libpcre missing)
mod_redirect : disabled (libpcre missing)
mod_ssi : disabled (libpcre missing)
I did install pcre. I can see pcre.config in /usr/local/bin/
Any clues? Or is this another “exercise for the reader”? ;)
Feb 28 at 21:10
Never mind. Something I did made the bad things go away. Wish I knew what it was. Lighttpd configures fine now. Maybe because of a restart?
Feb 28 at 21:44
I feel like saying “Gimminy, gimminy…” or something equally incoherent. It actually works.
I had to add /usr/local/sbin to my PATH first, though.
Oh, and don’t wait for any output in the terminal after starting lighttpd. I did, for five minutes, until I realized that it was running just fine :)
Mar 01 at 08:30
Thanks for the setup info. I’m at the point of trying to do make on lighttpd. Even though the mysql include files are there, and are where they were mentioned in the ./configure step, it’s failing to build with messages like this:
mod_mysql_vhost.c:13:25: mysql/mysql.h: No such file or directory
This is for 1.3.11, running on OSX 10.3.8. Any ideas?
Mar 01 at 21:07
To resolve my compile problem, I wound up simply tweaking the include for mysql.h in mod_mysql_vhost.c to be an absolute path.
Mar 06 at 20:12
I’ve taken a slightly different path for the MySQL server to use version 4.1.10 and mod_mysql_vhosts:
- using Fink doesn’t work because the 4.1.10 source from Fink doesn’t have mysql_config
- I installed the Mac OS X 10.3 package directly from dev.mysql.com
- lighttpd correctly finds mysql_config in /usr/local/mysql/bin BUT it apparently doesn’t care what this utility returns because it looks for the headers in /usr/local/incude/mysql instead of /usr/local/mysql/include (I guess this is a bug in lighhtpd)
- therefore, I had to create a symlink (sudo ln -s /usr/local/mysql/include /usr/local/include/mysql) to make lighttpd happy
Mar 06 at 20:16
Chris, your problem comes because lighttpd doesn’t care about what mysql_config returns for the path to the MySQL include folder. See my previous comment to create a symlink rather than modify the source code.
Mar 11 at 23:50
unfortunately the lighttpd.net site appears down at the moment. I will try again later.
Mar 12 at 00:11
ok, all set…
i downloaded the source from http://mir.zyrianes.net/gentoo/distfiles/lighttpd-1.3.13.tar.gz
and also having used the dmg from mysql.com i ran ./configure —with-mysql=/usr/local/mysql/bin/mysql_config
all is well, thanks for putting this together.
Mar 20 at 21:40
If you get:
<br /> mod_rewrite : disabled (libpcre missing)<br /> mod_redirect : disabled (libpcre missing)<br /> mod_ssi : disabled (libpcre missing)
Add /usr/local/bin to your $PATH variable i.e.
#PATH=$PATH:/usr/local/bin<br /> #export PATH