FreeBSD - Tutorials, Security
Home   Archives   Sitemap   About   Contact

LIGHTTPD - create virtual hosts - subdomains - quick how-to

Home NEW! Unix Forum News 100 Tips and Tricks Website Development Server Operating Systems Databases
 Ivorde.ROarrow Website Development arrowServer SidearrowLIGHTTPD - create virtual hosts - subdomains - quick how-to 

Article Sections

    Hello, Guest !
User name:
Password:
 
Google

 SSD VPS Hosting - Vpsie.com
 Mo.nitor.me
 Ivorde forum
 FreeBSD Tutorials
 Linux LVM Commands
 Free Shell Accounts
 FreeBSD Project
 FreeBSD Handbook
 Advanced Bash-Scripting Guide
 The OpenBSD Project
 Distrowatch
 FreeBSD Handbook


Apache Webserver Home Page

Posted on: 01 Feb 2008
Author: mandrei
Section: Website Development | Server Side
Views: 1086
Comments: 1 (Add)

LIGHTTPD - create virtual hosts - subdomains - quick how-to
create lighttpd subdomain, lighttpd virtual hosts, lighttpd configuration file, lighttpd restart

 



Lighttpd is a very light web server software that takes very few resources from your server, but also has fewer capabilities. When a website is serving both lots of images, javascripts, cascading style sheets(static content) and dynamic scripts (ASP, PHP, JSP or more), it is not wise to let apache serve both static and dynamic content. That is why, lighttpd can run besides apache on another port and serve requests for the static content of your website.

How to tell apache to redirect requests for static content to lighttpd (on another port, other than 80) is not the point of this tutorial.

The point is that the virtual host for the specific website/subdomain must be declared also in lighttpd configuration file, not only in apache's config file (httpd.conf).

How to create virtual hosts for Lighttpd

Use your favourite editor to open /etc/lighttpd/lighttpd.conf file (on Linux) or /usr/local/etc/lighttpd.conf (on FreeBSD) and, preferably at the bottom, add the following line (replace with what suits your needs the text in italic):

$HTTP["host"] =~ "www.domain.ro" {
server.document-root = "/home/www/domain.ro/public_html"
}

www.domain.ro is the domain for which you're declaring the virtual host and /home/www/domain.ro/public_html is the home directory for this domain where the static content resides (should be the same home directory declared in Apache's virtual host for this domain).

Now, in order for lighttpd to serve this domain, we must restart lighttpd. Here's how to do it on both Linux and FreeBSD:


Restarting lighttpd on Linux:

$ /etc/init.d/lighttpd restart
* Stopping lighttpd ... [ ok ]
* Starting lighttpd ... [ ok ]
================OR================
$ service lighttpd restart
* Stopping lighttpd ... [ ok ]
* Starting lighttpd ... [ ok ]

Restarting lighttpd on FreeBSD:

$ /usr/local/etc/rc.d/lighttpd restart

Now to test lighttpd configuration (we presume that apache's configuration is ok and requests for static content are redirected to http://127.0.0.1:xx, xx being the port on which lighttpd is listening) open your browser go to www.domain.ro:xx (xx is lighttpd's port).

If you see something it means it works. What you see depends on what's in the domain's home dir. Lighttpd meight not recognize dynamic content. Also make sure there are reading permissions for that directory and files (and so on..).

Also see  How to install lighttpd on FreeBSD

Bookmarks: Echo "LIGHTTPD - create virtual hosts - subdomains - quick how-to" around:
del.icio.usdiggFurlYahooMyWebGoogleBookmarksFaceBookTechnocratti
-------------------advertising-----------------

Other articles in Website Development / Server Side
» Apache: Individual logging for each domain or subdomain
» Apache+SSL How to build a secure webserver
» How to create onclick confirmations for hyperlinks
» How to set Apache not to log requests for images or java scripts
» PHP - How to isolate the first 10 words out of a large text




Contact webmaster regarding this article
Register or Login to post your article
Hello, Guest ! You can Login or Register to www.ivorde.ro!

 Post comment:

Name:
Title:
Comment:
Please type the word you see in the image (anti-spam verification). Refresh the page if you don't understand the word.
Allowed HTML Tags for comments:<p><strong><em><u><h1><h2><h3><h4><h5><h6><img><li>
<ol><ul><span><div><br><ins><del>

1 comment(s) to LIGHTTPD - create virtual hosts - subdomains - quick how-to:

1. Re: LIGHTTPD - create virtual hosts - subdomains - quick how-to
Software dev by Lindsay Kay at September 02nd, 2010 - 02:40
Thank you, just what I needed!

   Latest topics on the forum:
 
   Most viewed articles:
How to copy a mysql database using mysqldump - 9376 views
How to change a user's password in AIX with the output from ECHO command - 8635 views
FreeBSD: Add/remove an additional IP alias - 5609 views
Qmail relay to smarthost: How to route all mail to a smarthost - 3929 views
Print queues in AIX 5L - How to list print queues in AIX - 2884 views

   Latest 10 articles:
Qmail relay to smarthost: How to route all mail to a smarthost - 03 Feb 2009
EXIM 4 relay to smarthost: How to route all mail except local domain - 03 Feb 2009
Windows XP: print LISTEN ports and network connections using netstat - 30 Jan 2009
How to cut out first last n characters from each file name, from a filelist - 04 Nov 2008
Mozilla Firefox3 is now released - 18 Jun 2008
How to switch lower case to upper case and upper case to lower case in a string - 17 Jun 2008
How to rename files/directories to uppercase/lowercase character names - 17 Jun 2008
How to convert lower case to upper case letters in a shell script/command - 17 Jun 2008
Unix,Linux,FreeBSD - How to rename a list of files, replacing spaces inside their names - 12 Jun 2008
How to change a user's password in AIX with the output from ECHO command - 21 May 2008


Archives
» 2007  |  June  |  October  |  November  |  December
» 2008  |  January  |  February  |  March  |  April  |  May  |  June  |  November
» 2009  |  January  |  February



Home | Archives | Sitemap | About | Contact

Designed and developed by Andrei Manescu. Optimized for Mozilla Firefox.  
Copyright 2007 Andrei Manescu
All trademarks and copyrights on this page are owned by their respective owners. Comments are owned by those who posted them.
Valid W3 Document Valid XHTML 1.0 Transitional Valid CSS! The FreeBSD Project Viewable With Any Browser