Jun
30th
 

Setting up a Basic Lighttpd Server

Posted by admin in Server

Lighttpd is geared for speed, and has a smaller footprint than Apache. Having a decreased footprint is critical when the server is in high stress situations and when available hardware is scarce. Popular websites such as Youtube and Imageshack who receive great amounts of traffic each minute are served up by Lighttpd.

How to install Lighttpd and have a basic functioning server:

First, get the newest source from http://www.lighttpd.net .

Then login as super user:

user@linux-588u:~> su
Password:
linux-588u:/home/user #

Unpack using:

linux-588u:/home/user/desktop #  tar -xf /home/user/lighttpd-1.4.22.tar.gz

Then change the directory to where the Lighttpd source got unpacked:

linux-588u:/home/user/desktop #  cd /home/user/lighttpd-1.4.22
linux-588u:/home/user/lighttpd-1.4.22 #

Use the configure script, compile, and install:

linux-588u:/home/user/lighttpd-1.4.22 #  ./configure && make && make install

Now run lighttpd:

linux-588u:/home/user #  lighttpd

If Lighttpd installed correctly, you should get something like this:

2009-06-26 01:35:52: (server.c.552) No configuration available. Try using -foption.

Ok, now that we have Lighttpd installed, we can move onto creating the config file so Lighttpd can run correctly.

We will create the config file in the /etc directory using vi:

linux-588u:/home/user #  vi /etc/lighttpd.conf

This will bring up vi where we can add the following for a basic Lighttpd server, press the insert key then enter:

server.document-root = "/home/user/www/htdoc"
 
server.port = 80
 
mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)
 
static-file.exclude-extensions = ( ".fcgi", ".php", ".py" )
 
index-file.names = ( "index.html", "index.py" )
 
server.modules = (
"mod_access",
"mod_cgi"
)
 
cgi.assign = ( ".py" => "/usr/bin/python",
                   ".php" => "/usr/bin/cgi-php")

After entering the config script, hit the escape key and type “wq” then enter to save and quit.

Now to get the server running with the conf file:

linux-588u:/home/user #  lighttpd -f /etc/lighttpd.conf
2009-06-26 01:52:36: (log.c.97) server started

Congratulations, you now have a working Lighttpd setup!

Config File Explained

“server.document-root”

Sets the document root for the server, where index.html and other files that need to be available to the web user.

“server.port”

Sets the port, TCP port 80 being the default port for http.

“mimetype.assign”

Sets the mimetype mappings.

“static-file.exclude-extensions”

Tells Lighttpd that these file types are handled by a cgi plugin that has been enabled. ( mod_cgi )

“server.modules”

Tells Lighttpd what modules to load.

“cgi.assign”

Tells what file types are handled by a cgi program.

For further information, visit http://www.lighttpd.net.




One Response to “Setting up a Basic Lighttpd Server”

  1. Softweb says:

    Good tutorial, thank you!

    Quote

Leave a Reply

Search



Categories