Replacing Apache with lighttpd

replacing-apache-with-lighttpd

As a precursor to researching Apache replacements for work, I decided to look at lighttpd at home. I already have php5 installed (incluing fast-cgi support). Here is how I installed lighttpd in my setup. These steps were carried out as root.

cd /usr/ports/www/lighttpd
make install clean

I had to make sure mysql support was included, and dropped ipv6 support (Serisouly, I’m not going to see v6 for years). Didn’t take long to compile, so straight to configuring:

Edit the file /usr/local/etc/lighttpd.conf and uncomment the line “mod_cgi”, “mod_fastcgi” and uncomment the entire section under #### fastcgi module. This enables php to work. Save the file and exit.

Lighttpd logs to /var/log/, so lets create the files now to avoid problems later:

cd /var/log
touch lighttpd.error.log
touch lighttpd.access.log
chown www:www lighttpd.error.log
chown www:www lighttpd.access.log

and for good measure create the folder for the pid file and make www the owner and group:

/var/run/lighttpd/ and
chown www:www /var/run/lighttpd/

Configuring the server to start on boot is as simple as editing /etc/rc.conf, but we also need to specify the location of the configuration file in another parameter. Add these lines to /etc/rc.conf:

lighttpd_enable=yes
lighttpd_conf=/usr/local/etc/lighttpd.conf

and now start it up with something like:

/usr/local/etc/rc.d/lighttpd.sh start

Mine started flawlessly.

One Response

  1. jayson Says:

    Really efficient article. I was looking for quick and usefull server instal on BSD, i found a great site.
    Thanks

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.