Shared hosting

Let us analyze the concept of “virtual hosting” and the technology of its creation (settings) in stages. It is a technique for storing the content of Web sites with a different domain or hostnames on a single server. For example, the names www.mystore.com and www.frankspage.com can have the same IP address in DNS, and Apache serves both of these sites (as well as its own hostname, which is specified by the ServerName directive ).

What software do you need for shared hosting?

One Apache for shared hosting is enough to service all requests, which simplifies administration and saves IP addresses. However, hacking increases the harm because the cracker gains access to all sites.

HTTP / 1.0 does not specify a hostname. Therefore, previously virtual hosting was only possible when each hostname was assigned a separate IP address (with the subsequent creation of IP aliases pointing to the same Ethernet card). Each virtual host was identified by an IP address, and a request from a Web browser always received a page from the corresponding Web site in response. The disadvantage of this approach was that binding large blocks of IP addresses to the same card became cumbersome and led to unnecessary consumption of IP address space.

With the advent of the HTTP / 1.1 protocol version, this process has been greatly simplified. The required Host header: specifies the hostname to look for, which is why virtual hosts, distinguished by name, have become the norm on the Internet today. Clients not supporting the Host header: are extremely rare now. Next, we discuss an exclusively new version of shared hosting. If you are interested in using IP-based virtual hosting, refer to the documentation available on the Apache website.

Most of the httpd.conf file defines the default server — a global set of definitions that apply to all requests received by the Apache server. In the default server, the ServerName directive is primarily used to construct a 301 URL redirect. You can also use a small set of directives to override global settings when the Host: header matches a specific hostname. These sets of rules are virtual hosts.

Let’s assume the server is called stripes.somewhere.com. Its name is specified in the main directive ServerName. To configure virtual hosting by name, use the NameVirtualHost directive with an argument * (this surrogate symbol means “all hosts”), followed by the required number of different blocks:

VirtualHost block example:
NameVirtualHost *
ServerName www.somewhere.com
DocumentRoot / usr / local / www / data
ServerAdmin webmaster@somewhere.com
ErrorLog logs / www.somewhere.com-error_log
CustomLog logs / www.somewhere.com-access_log common
ServerName www.frankspage.com
ServerAlias ​​frankspage.com
DocumentRoot / home / frank / public_html
ServerAdmin frank@frankspage.com
ErrorLog logs / www.frankspage.com-error_log
CustomLog logs / www.frankspage.com-access_log common
Inside the container, the ServerName directive specifies the hostname. The DocumentRoot directive specifies where the root of the file system is for an incoming request, and ErrorLog and CustomLog are alternate log files for each virtual host. ServerAlias allows you to enumerate virtual host aliases. In the block, any other directives can be included.

It is important to note that with the settings above, requesting the default server ( stripes.somewhere.com ) or any other hostname that matches the server’s IP address but does not match any of the blocks, will not be processed.

An example of a more correct VirtualHost block:
NameVirtualHost *
ServerName stripes.somewhere.com
ServerAlias ​​* .somewhere.com
DocumentRoot / usr / local / www / data
ServerAdmin webmaster@somewhere.com
ErrorLog logs / www.somewhere.com-error_log
CustomLog logs / www.somewhere.com-access_log common

ServerName www.frankspage.com
ServerAlias ​​frankspage.com
DocumentRoot / home / frank / public_html
ServerAdmin frank @ frankspage.com
ErrorLog logs / www.frankspage.com-error_log
CustomLog logs / www.frankspage.com-access_log common
Virtual hosts can be created in many ways: by specifying different IP addresses and ports in blocks

For more details:

https://www.evernote.com/shard/s736/client/snv?noteGuid=3b5d2593-c2b9-4113-11e9-6ab39f0904ba&noteKey=7359c9578b937883f6d2343d23e2e9ec&sn=https%3A%2F%2Fwww.evernote.com%2Fshard%2Fs736%2Fsh%2F3b5d2593-c2b9-4113-11e9-6ab39f0904ba%2F7359c9578b937883f6d2343d23e2e9ec&title=Hosting%2BPHP%2Band%2BMySQL%2Bor%2Bwhat%2Btechnologies%2Bare%2Bbetter%2Bfor%2Bmaking%2Bsites

Published
Categorized as Journal