Setup lighttpd 1.4.18 Virtual Hosting in CentOS 5

What is a virtual hosting? It is a method that web servers such as lighttpd is use to host more than one domain name on the same server or on the same IP address. Virtual hosting can be accomplished in two methods such as ip-based virtual hosting and name-based virtual hosting. In this post, I will setup lighttpd 1.4.18 virtual hosting based on name-based virtual hosting to host, (both and is referring to the same website) and on 1 single web server.

1. Create each of the website directory like this: –

mkdir /srv/www/lighttpd/
mkdir /srv/www/lighttpd/

2. Open lighttpd configuration file like this: –

vi /etc/lighttpd/lighttpd.conf

3. Add below text to support and at the end of file: –

$HTTP["host"] =~ "^(|" {
server.document-root = "/srv/www/lighttpd/"

4. Add below text to support at the end of file: –

$HTTP["host"] == "" {
server.document-root = "/srv/www/lighttpd/"

5. Save and exit file. Restart the lighttpd service like this: –

service lighttpd restart

6. Upload respective HTML files. Point your browser to the website and you will see the respective website.

If you found these helpful, please contribute to help:

Source: lighttpd