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 domain1.com, www.domain1.com (both domain1.com and www.domain1.com is referring to the same website) and www2.domain2.com on 1 single web server.
1. Create each of the website directory like this: -
mkdir /srv/www/lighttpd/domain1.com
mkdir /srv/www/lighttpd/www2.domain2.com
2. Open lighttpd configuration file like this: -
vi /etc/lighttpd/lighttpd.conf
3. Add below text to support domain1.com and www.domain1.com at the end of file: -
$HTTP["host"] =~ “^(domain1.com|www.domain1.com)” {
server.document-root = "/srv/www/lighttpd/domain1.com"
}
4. Add below text to support www2.domain2.com at the end of file: -
$HTTP["host"] == “www2.domain2.com” {
server.document-root = "/srv/www/lighttpd/www2.domain2.com"
}
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
Why lighttpd and not Apache? First of all, what is lighttpd? These four words can describe lighttpd - security, speed, compliance, and flexibility. lighttpd (pron. lighty) is a web server that has been optimized for high performance environment. With its very low memory footprint compared to other web servers, takes care of CPU load and advanced feature-set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) makes lighttpd the perfect web server software for every server that suffers load problems. Best of all lighttpd powers several popular Web 2.0 sites like YouTube, wikipedia and meebo.











A simple guy trying to put his name into the WWW place.