Virtual Hosting: Home: Difference between revisions
(New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | MPG UniCenter || Virtual Hosting: [[Virtual Hosting: Home | Ho...) |
(Ffix grammatical stuff and clarify) |
||
Line 18: | Line 18: | ||
'''Virtual Hosting'''<br>'''Uniform Server 3.5-Apollo''' | '''Virtual Hosting'''<br>'''Uniform Server 3.5-Apollo''' | ||
|} | |} | ||
Virtual hosting is extremely powerful | Virtual hosting is extremely powerful. It allows you to host several domain names using a single Apache server. Before looking at Vhosts in detail the following background information may be of use. Certainly take a look at [[#Root folders | root folders]]. | ||
== Web Server == | == Web Server == | ||
The sole task of a web server (Apache) is to translate a URL into a file name and send that file back over the Internet to a client (browser). URLs may translate to a program which Apache runs and sends the resulting output back. URLs are packages of information arriving on port 80 of the host machine. What’s important Apache will process any URL on this port regardless of its origin. | The sole task of a web server (Apache) is to translate a URL into a file name and send that file back over the Internet to a client (browser). URLs may translate to a program which Apache runs and sends the resulting output back. URLs are packages of information arriving on port 80 of the host machine. What’s important is that Apache will process any URL on this port regardless of its origin. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Clients == | == Clients == | ||
URLs consist of several pieces of information basics are provided when a user types a web page address into a browser or clicks a page link. Once initiated a browser assembles all the pieces into a complete URL. It converts the domain name into an IP address (where the server can be found) adds a return IP address (allows information to be sent back to the client) adds other pieces to the original request | URLs consist of several pieces of information. The basics are provided when a user types a web page address into a browser or clicks a page link. Once initiated a browser assembles all the pieces into a complete URL. It converts the domain name into an IP address (where the server can be found) adds a return IP address (allows information to be sent back to the client) and adds other pieces to the original request. For example, referrer, once assembled, is sent to the server. | ||
It's important to note that different domain names can and do resolve to the same server IP address. A URL package of information allows Apache to separate out individual domains, giving the illusion of a dedicated server for that domain name. To achieve this operation, you create a Virtual Host section in Apache’s configuration file for each domain name. | |||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Root folders == | == Root folders == | ||
A root folder is a folder you wish to make public to anyone on the Internet. Default for Uniform Server is folder www | A root folder is a folder you wish to make public to anyone on the Internet. Default for Uniform Server is folder www. All its content (sub-folders, files images etc) are potentially accessible by Internet users. You can restrict certain areas as needed using .htaccess files. | ||
Root folder names are not visible from the Internet | Root folder names are not visible from the Internet. Any folder above a root folder is not accessible, while folders and files within and below the root are. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Root folder location == | == Root folder location == | ||
Root folders are nothing special | Root folders are nothing special. They are the same as any other folder on your PC. There are no restrictions where a root folder is located. They can be on the same hard drive as the server or on separate hard drives. In general you would allocate one root folder per domain name. However if you wish, the same root folder may be accessed by different domain names. In this case you would be serving the same site content. | ||
'''''Note'':''' If you are hosting several domain names and want to retain Uniform Server portability you must locate site root folders within or below folder udrive. | '''''Note'':''' If you are hosting several domain names and want to retain Uniform Server portability you must locate site root folders within or below folder udrive. | ||
Line 42: | Line 42: | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Folder paths == | == Folder paths == | ||
The tutorial that follows shows how to host three sites | The tutorial that follows shows how to host three sites. In reality you require an extra site referred to as the default. If for whatever reason Apache cannot resolve an incoming request it will automatically redirect to this default site, which contains a single page with a polite message informing users why they have been redirected. | ||
You are free to place root folders where you like however their location impacts | You are free to place root folders where you like, however their location impacts the paths you specify in each host block. The following explains this in a little more detail. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
Line 54: | Line 54: | ||
[[Image:Uc_vhost_3_a.gif]] | [[Image:Uc_vhost_3_a.gif]] | ||
|valign="top"| | |valign="top"| | ||
Web sites 1 to 3 are large | Web sites 1 to 3 are large. These will not fit on a USB stick, so they have been located at the top level of '''drive I'''. These sites could also have been placed on their own drives. | ||
They are not portable | They are not portable. When Uniform Server is run, they are not reflected in the virtual drive (w) created. See image on the right. | ||
When you specify DocumentRoot the full path to a folder must be supplied. | When you specify DocumentRoot the full path to a folder must be supplied. | ||
Line 63: | Line 63: | ||
*I:/site3 | *I:/site3 | ||
'''''Note 1'':''' Moving Uniform server to a USB stick | '''''Note 1'':''' Moving Uniform server to a USB stick: When run on a different machine, Apache will fail to start. This is because Apache detects a configuration error (cannot find the root folders). | ||
'''''Note 2'':''' In this example the extra site (default site) can be the main root folder www saves creating an extra root folder. | '''''Note 2'':''' In this example the extra site (default site) can be the main root folder www, which saves creating an extra root folder. | ||
| | | | ||
[[Image:Uc_vhost_3_b.gif]] | [[Image:Uc_vhost_3_b.gif]] | ||
Line 73: | Line 73: | ||
---- | ---- | ||
=== Configuration 2 === | === Configuration 2 === | ||
Where you place root folders tends to be a personal choice | Where you place root folders tends to be a personal choice. This configuration reflects the way I implement my sites. I have assumed all three sites will fit on my USB stick. I have located these sites in folder www. This no longer functions as a root folder; it is used purely as general-purpose folder. I have created a separate folder, site_default, which will be used as the default. | ||
{| | {| | ||
|- | |- | ||
Line 89: | Line 89: | ||
*I:/us_test_server/Uniform Server/udrive/www/site_default | *I:/us_test_server/Uniform Server/udrive/www/site_default | ||
'''Portable''' Apache runs on the virtual drive created | '''Portable''' Apache runs on the virtual drive created. Because our site folders are reflected in this drive, it makes sense to use paths relative to this drive. More importantly there is no need to specify a drive letter. Use “/” to start from the top level. This gives the following paths (see image on the right): | ||
*/www/site1 | */www/site1 | ||
*/www/site2 | */www/site2 | ||
Line 98: | Line 98: | ||
[[Image:Uc_vhost_2_b.gif]] | [[Image:Uc_vhost_2_b.gif]] | ||
|} | |} | ||
This configuration has one minor disadvantage | This configuration has one minor disadvantage. It is not compatible with apanel’s Vhosts. I have no problem with this because I manually edit the files by choice. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
---- | ---- | ||
=== Configuration 3 === | === Configuration 3 === | ||
This configuration I use in the tutorial | This is the configuration I use in the tutorial. Although not portable, it highlights several points. I have assumed site 1 is too large to fit on a USB stick hence is placed in the disk root (top level). | ||
I have created a common folder z_www and placed the site root folders in this. The main root folder www becomes the default site, which has been automatically created. When using Vhost from apanel you will find this listed as default. | I have created a common folder z_www and placed the site root folders in this. The main root folder www becomes the default site, which has been automatically created. When using Vhost from apanel you will find this listed as default. | ||
Line 112: | Line 112: | ||
[[Image:Uc_vhost_1_a.gif]] | [[Image:Uc_vhost_1_a.gif]] | ||
|valign="top"| | |valign="top"| | ||
Path choice, site 1 dictates you use an absolute path, sites 2 and 3 you have two options either absolute or relative to the virtual drive. It’s probably a good to make 2 and 3 portable hence use paths relative to the virtual drive. | Path choice, site 1 dictates you use an absolute path, but for sites 2 and 3 you have two options: either absolute or relative to the virtual drive. It’s probably a good to make 2 and 3 portable hence use paths relative to the virtual drive. | ||
*I:/site1 | *I:/site1 | ||
*/z_www/site2 | */z_www/site2 | ||
Line 118: | Line 118: | ||
'''''Note 1'':''' | '''''Note 1'':''' Regarding file paths, Apache is consistent between Unix and Windows. '''Always''' use a forward slash as shown. | ||
'''''Note 2'':''' Root folder names (site1, site2 and site3) are not significant | '''''Note 2'':''' Root folder names (site1, site2 and site3) are not significant. Choose whatever you like, however make your life easy and NEVER use spaces; use an underscore instead. That includes file names, too. | ||
| | | | ||
[[Image:Uc_vhost_1_b.gif]] | [[Image:Uc_vhost_1_b.gif]] | ||
Line 126: | Line 126: | ||
== Summary == | == Summary == | ||
The above gives you a feel for what’s going on | The above gives you a feel for what’s going on. It's all about Apache finding the root folders so it can serve pages from them. On the [[Virtual Hosting: Name based |next page]] I expand the ideas and show how easy it is to use apanel to set-up virtual hosts. | ||
Latest revision as of 00:07, 10 January 2010
Virtual Hosting: Home | Name based | PAC | Browsers and PAC | Making it portable | Issues |
Virtual Hosting |
Virtual hosting is extremely powerful. It allows you to host several domain names using a single Apache server. Before looking at Vhosts in detail the following background information may be of use. Certainly take a look at root folders.
Web Server
The sole task of a web server (Apache) is to translate a URL into a file name and send that file back over the Internet to a client (browser). URLs may translate to a program which Apache runs and sends the resulting output back. URLs are packages of information arriving on port 80 of the host machine. What’s important is that Apache will process any URL on this port regardless of its origin.
Clients
URLs consist of several pieces of information. The basics are provided when a user types a web page address into a browser or clicks a page link. Once initiated a browser assembles all the pieces into a complete URL. It converts the domain name into an IP address (where the server can be found) adds a return IP address (allows information to be sent back to the client) and adds other pieces to the original request. For example, referrer, once assembled, is sent to the server.
It's important to note that different domain names can and do resolve to the same server IP address. A URL package of information allows Apache to separate out individual domains, giving the illusion of a dedicated server for that domain name. To achieve this operation, you create a Virtual Host section in Apache’s configuration file for each domain name.
Root folders
A root folder is a folder you wish to make public to anyone on the Internet. Default for Uniform Server is folder www. All its content (sub-folders, files images etc) are potentially accessible by Internet users. You can restrict certain areas as needed using .htaccess files. Root folder names are not visible from the Internet. Any folder above a root folder is not accessible, while folders and files within and below the root are.
Root folder location
Root folders are nothing special. They are the same as any other folder on your PC. There are no restrictions where a root folder is located. They can be on the same hard drive as the server or on separate hard drives. In general you would allocate one root folder per domain name. However if you wish, the same root folder may be accessed by different domain names. In this case you would be serving the same site content.
Note: If you are hosting several domain names and want to retain Uniform Server portability you must locate site root folders within or below folder udrive.
Folder paths
The tutorial that follows shows how to host three sites. In reality you require an extra site referred to as the default. If for whatever reason Apache cannot resolve an incoming request it will automatically redirect to this default site, which contains a single page with a polite message informing users why they have been redirected.
You are free to place root folders where you like, however their location impacts the paths you specify in each host block. The following explains this in a little more detail.
Configuration 1
Web sites 1 to 3 are large. These will not fit on a USB stick, so they have been located at the top level of drive I. These sites could also have been placed on their own drives. They are not portable. When Uniform Server is run, they are not reflected in the virtual drive (w) created. See image on the right. When you specify DocumentRoot the full path to a folder must be supplied.
Note 1: Moving Uniform server to a USB stick: When run on a different machine, Apache will fail to start. This is because Apache detects a configuration error (cannot find the root folders). Note 2: In this example the extra site (default site) can be the main root folder www, which saves creating an extra root folder. |
Configuration 2
Where you place root folders tends to be a personal choice. This configuration reflects the way I implement my sites. I have assumed all three sites will fit on my USB stick. I have located these sites in folder www. This no longer functions as a root folder; it is used purely as general-purpose folder. I have created a separate folder, site_default, which will be used as the default.
Non-portable If I want a fixed installation I would use absolute paths as follows:
Portable Apache runs on the virtual drive created. Because our site folders are reflected in this drive, it makes sense to use paths relative to this drive. More importantly there is no need to specify a drive letter. Use “/” to start from the top level. This gives the following paths (see image on the right):
|
This configuration has one minor disadvantage. It is not compatible with apanel’s Vhosts. I have no problem with this because I manually edit the files by choice.
Configuration 3
This is the configuration I use in the tutorial. Although not portable, it highlights several points. I have assumed site 1 is too large to fit on a USB stick hence is placed in the disk root (top level).
I have created a common folder z_www and placed the site root folders in this. The main root folder www becomes the default site, which has been automatically created. When using Vhost from apanel you will find this listed as default.
Path choice, site 1 dictates you use an absolute path, but for sites 2 and 3 you have two options: either absolute or relative to the virtual drive. It’s probably a good to make 2 and 3 portable hence use paths relative to the virtual drive.
Note 2: Root folder names (site1, site2 and site3) are not significant. Choose whatever you like, however make your life easy and NEVER use spaces; use an underscore instead. That includes file names, too. |
Summary
The above gives you a feel for what’s going on. It's all about Apache finding the root folders so it can serve pages from them. On the next page I expand the ideas and show how easy it is to use apanel to set-up virtual hosts.
Ric |