Configuring lighttpd for use with Asterisk & FreePBX
I recently had a client that wanted to install Asterisk and FreePBX on a machine that was already running Apache so I though I’d have a go at getting it working with lighttpd instead.
It is pretty easy to setup and worked well. The instructions below are for CentOS 5.1.
Here’s how to set it up. You will probably need to alter this for your environment but it’ll be a good starting point.
Prerequisites
You need to have already installed Asterisk and FreePBX. When installing FreePBX you should choose a unique location for the install rather than the Apache default - /var/www/html. I chose /var/www/freepbx.
Installing lighttpd
I chose to install lighttpd from rpmforge but you could just as easy compile it from source.
See here for details on setting up rpmforge - http://dag.wieers.com/rpm/FAQ.php#B
yum install lighttpd lighttpd-fastcgi
Lighttpd configuration file changes
Change or add the following lines from the default lighttpd configuration file
server.document-root = "/var/www/freepbx"
server.port = 81
server.username = "asterisk"
server.groupname = "asterisk"
server.pid-file = "/var/run/lighttpd/lighttpd.pid"
server.modules = ( "mod_fastcgi", "mod_auth" )
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/lighttpd.pem"
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/.passwd"
auth.debug = 2
auth.require = ( "/" =>
(
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)
Generate the SSL certificate
openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes
chown asterisk:asterisk lighttpd.pem
chmod 600 lighttpd.pem
Create the password file
Set some access rights
mkdir /var/run/lighttpd
chown -R asterisk:asterisk /var/run/lighttpd/
Start Lighttpd
service lighttpd start
And that’s it. You should now be able to connect to FreePBX on port 81 using HTTPS.
You should be asked for a username/password which, if you followed the instructions above, will be ‘bob’ and whatever password you chose.
Related posts:
- Using callwithus with Asterisk, FreePBX and A2Billing
- UK based Asterisk VPS with FreePBX and A2Billing
- Getting the DID number from a CallCentric SIP trunk for FreePBX

Leave a comment