Lighttpd logo

Virtual hosting is nothing but the provision of Web server hosting services so that a company (or individual) doesn’t have to purchase and maintain its own Web server and connections to the Internet.

Lighttpd does support or allows you to bind more than two IP address simultaneously using $SERVER[“socket”]..

For example,
IP # 1: domain
IP # 2: domain

Open lighttpd.conf file:
# vi /etc/lighttpd/lighttpd.conf

First use server.bind and server.port to setup IP
server.port = 80
server.bind = ""

Now define virtual host:
$HTTP["host"] == "" {
server.document-root = "/home/lighttpd/"
server.errorlog = "/var/log/lighttpd/"
accesslog.filename = "/var/log/lighttpd/"

Next use $SERVER[“socket”] to bind for domain:
$SERVER["socket"] == "" {
server.document-root = "/home/lighttpd/"
server.errorlog = "/var/log/lighttpd/"
accesslog.filename = "/var/log/lighttpd/"
Save and close config file. Restart the lighttpd:
# /etc/init.d/lighttpd restart

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • slav0nic Dec 1, 2007 @ 18:34

    good, but if i has 2 domain on ? =)

  • 🐧 nixCraft Dec 1, 2007 @ 20:16

    Go here. If you have more question use our forum.

  • Kathleen J Caunter Jan 12, 2008 @ 23:34

    i am confused on how to fix this problem everytime i try to sumit info on a forum it states website cant display this page i dont understand what to do i am ok with computers but this problem fixer is confusing to me caan you help me please as i have important info to sumit on this forum about my custom show car and it was suppose to be sumitted by thiss weekend sun night the latest caan you please put it in simple terms i would apprecciate your help so much Kathy

  • Nazz Apr 30, 2008 @ 7:49

    I’m trying to use lighttpd with virtual hosting and different ssl certs for each host. I have one ip that is external and one virtual ip on the same machine.

    I have both of the ips set, but since they are the same server, I always get the same certificate. Adding a host check doesn’t work and when I do that neither site works via ssl.

    $SERVER[“socket”] == “” {

    $HTTP[“host”] =~ “” {
    ssl.engine = “enable”
    ssl.pemfile = var.confdir + “/www.” = var.confdir + “/gd_intermediate.crt” = var.confdir + “/”


    $SERVER[“socket”] == “” {

    $HTTP[“host”] =~ “” {
    ssl.engine = “enable”
    ssl.pemfile = var.confdir + “/” = var.confdir + “/gd_intermediate.crt” = var.confdir + “/”


    I guess it won’t work with virtual ips. Anyone know about this?

  • soraver Feb 23, 2009 @ 12:49

    be carefull
    sometimes server.bind does not work.

    for me at least it didnt. i had to comment the ipv6 line
    #include_shell “/usr/share/lighttpd/”
    that was above server.socket in my example config file in debian lenny.

  • Gokul Jul 19, 2010 @ 7:31

    you can simply use

    $HTTP[“host”] =~ “yourdomain” {
    server.bind = “yourip”
    server.port = 80

    • Gokul Jul 19, 2010 @ 9:14

      The above command has a small issue,

      The easy work around is goto your /etc/hosts file and set the IP against each domain

      That will solve this issue.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum