A web server is identified by an IP address and a port name (which defaults to 80 for http and 443 for https). But what if we want to host more than one web site? Ages ago it would mean having multiple IP addresses on a server, one per web site, or using non-standard port numbers (like . Both solutions are no bargain: an IP address space is limited, and non-standard port number means a user should memorize it.
The glorious solution was described in version 1.1 of http protocol standard, and it is pretty simple. A web browser must add a “Host:” header to any http request, with its value set to a hostname part of an address hat user has typed in a location field. Now, if you want to browse the request containing “Host: ” header is sent to a specific IP address. In the end you use the same IP for , too, or maybe hundreds of such sites. Yes, this is how shared web hosting works. There is usually one web server listening to one IP/port combination, which reads the "Host:" header and supply the content based on its value.
A small talk nerdy to me part for those who are eager to know all the small details. In shared hosting there’s one copy of the Apache web server running plus, let's say, PHP installed either as mod_php, or as a CGI executable. That one copy of Apache handles all the incoming HTTP requests for all the websites that are sharing the server: receiving, processing, sending back a static file (say, an image), running scripts, logging and so on. When Apache is running in this way it runs as a single user, usually www or apache. At the moment Apache + mod_php is the fastest way of runnin PHP scripts, as the PHP interpretor is persistent and in-process, leaving two others (CGI + SuEXEC and FastCGI per user) far behind.
All the above might seem to be a brilliant scheme from the first look, but there are a number of drawbacks. Since it's just one http server instance serving multiple sites, a load on one of such sites will cause a slowdown of all the others, and that's just a mild scenario, more real-world one would be a DDoS attack on a site, rendering not only this one, but all the others dead and non-responsive. This is because there is no way to control resources (CPU time, disk and network bandwidth, used RAM etc.) on a per web site basis.
Another problem with shared hosting is security, or rather a lack of it. In a shared environment, different web sites are just different directories, usually there's little or no separation between those. All the web sites accounts and Apache user are members of the same group, so the thing is that Apache user has read (and sometimes even write) access to all the files of all the websites residing on the same server. If one of the sites is hacked, most probably others are vulnerable, too. More than that, evil hacker can just easily become a customer, get a legitimate account on the box, and then just upload PHP scripts to access the other websites hosted on the box (including all the PHP scripts that contain usernames and passwords for all the MySQL databases. Already having a panic attack? Clutching your head and wondering, what to do?
The simple answer lately was 'go for dedicated hosting' (which means having a distinct physical server for every given web site). Thanks to modern technologies and dark powers of electricity, these days those servers can be virtual dedicated ones, just multiple virtual machines running on top of one physical server (yeah, remember those VPSes you heard of?). This or that way, this looks very much like a trip back to 1990s (along with NAFTA, Hubble telescope, MMORPGs and Red Hot Chili Peppers): single IP per web server, administrating/management nightmares, and so on. Do we REALLY have to choose between good old one server per web site , or a shared hosting?
In CloudLinux, we can have the best of both worlds. It is shared hosting, but with decent resource controls applied to make those web sites more independent of each other. In a nutshell, the CloudLinux technology makes web server processes that handle the request of a specific web site be bound by resource constraints specified for this very site. Remember that “Host:” header which tells a web server what site a client wants? Whenever Apache in CloudLinux sees that, it jumps into so-called LVE (lightweight virtual environment) dedicated to this specific site. Now, with the help of CloudLinux, you can host multiple sites in a same shared manner, but have things about as safe an in case of dedicated hosting, specifying priorities and resource constraints for each of those sites. Now, if one site has a huge increase in traffic, it won't affect the others and make them slow and unresponsive (if a system is configured properly). You need to give it a try. You will be amazed. I guarantee it.
