487
edits
(New page: {{Uc_nav_apanel2}} '''Admin Virtual Host''' Name based virtual hosting allows you to either host or develop more than one web site on your Apache server. Its main advantage only one fixed...) |
(Swept up a bit) |
||
Line 2: | Line 2: | ||
'''Admin Virtual Host''' | '''Admin Virtual Host''' | ||
Name based virtual hosting allows you to | Name based virtual hosting allows you to host and/or develop more than one web site on your Apache server. Its main advantage is that only one fixed IP is required to host several sites, hence preserving those valuable IP addresses. This tool simplifies setting up the Apache configuration and local host files by making that process transparent. | ||
'''Error''' | '''Error''' | ||
When you first start this page you will find a host named '''localhost:80''' followed by one error message. In reality this error message is just a warning and can be safely ignored. Note localhost:80 is a dummy server name. If you are hosting one web site under one domain name there is no need to use virtual hosting | When you first start this page you will find a host named '''localhost:80''' followed by one error message. In reality this error message is just a warning and can be safely ignored. Note: localhost:80 is a dummy server name. If you are hosting one web site under one domain name there is no need to use virtual hosting. You should be using the normal set-up explained in Apache Configuration [[Admin Panel 2: Apache Configuration#Server Name|Server Name]]. | ||
== Virtual hosting == | == Virtual hosting == | ||
Line 18: | Line 18: | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Log files == | == Log files == | ||
Uniform Server by | Uniform Server, by default, logs all errors and accesses to the server in the following two files '''error.log''' and '''access.log''', respectively located in folder *\Uniform Server\udrive\usr\local\apache2\logs you may prefer to have separate logs for each virtual host. | ||
To have separate logs when filling in the Admin Virtual Host form (Optional additions) you add the following two lines to each virtual host | To have separate logs when filling in the Admin Virtual Host form (Optional additions) you add the following two lines to each virtual host: | ||
{| cellpadding="8" cellspacing="1" style="background:#000000;" | {| cellpadding="8" cellspacing="1" style="background:#000000;" | ||
Line 28: | Line 28: | ||
|} | |} | ||
The file names '''name_error.log''' and '''name_custom.log''' can be anything you like I would recommend you use site folder names it makes administration easier. | The file names '''name_error.log''' and '''name_custom.log''' can be anything you like. I would recommend you use site folder names, since it makes administration easier. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
=== CustomLog Directive === | === CustomLog Directive === | ||
The CustomLog Directive takes three parameters file name, format (what to log) and environment | The CustomLog Directive takes three parameters: file name, format (what to log) and environment. The first two are required and the third is optional. | ||
The second parameter specifies what will be written to the log file (if this is missing it prevents the server running) UniServer has the following defined: | The second parameter specifies what will be written to the log file (if this is missing, it prevents the server running) UniServer has the following defined: | ||
{| cellpadding="8" cellspacing="1" style="background:#000000;" | {| cellpadding="8" cellspacing="1" style="background:#000000;" | ||
|style="background:#f5f5f5;"| | |style="background:#f5f5f5;"| | ||
LogFormat "%h % %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User- | LogFormat "%h % %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" '''combined'''<br> | ||
LogFormat "%h %l %u %t \"%r\" %>s %b" '''common'''<br> | LogFormat "%h %l %u %t \"%r\" %>s %b" '''common'''<br> | ||
LogFormat "%{Referer}i -> %U" '''referer'''<br> | LogFormat "%{Referer}i -> %U" '''referer'''<br> | ||
Line 44: | Line 44: | ||
|} | |} | ||
Each format string ends with a name (combined, common, referer and agent) | Each format string ends with a name (combined, common, referer and agent). These are short cuts containing the corresponding format string. You use this name as the second parameter for each custom log. | ||
{| cellpadding="8" cellspacing="1" style="background:#000000;" | {| cellpadding="8" cellspacing="1" style="background:#000000;" | ||
Line 57: | Line 57: | ||
|style="background:#f5f5f5;"| | |style="background:#f5f5f5;"| | ||
ErrorLog logs/name_error.log<br> | ErrorLog logs/name_error.log<br> | ||
CustomLog logs/name_custom.log '''"%h % %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User- | CustomLog logs/name_custom.log '''"%h % %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""''' | ||
|} | |} | ||
Line 86: | Line 86: | ||
|} | |} | ||
Open the file '''httpd.conf''' located in folder '''*\Uniform Server\udrive\usr\local\apache2\conf''' | Open the file '''httpd.conf''' located in folder '''*\Uniform Server\udrive\usr\local\apache2\conf''' . The virtual host entries are added to the end of this file. | ||
The first line NameVirtualHost * enables Apache for virtual host operation. If you comment out this line by adding "#" it disables all the hosts you have configured. | The first line NameVirtualHost * enables Apache for virtual host operation. If you comment out this line by adding "#" it disables all the hosts you have configured. | ||
'''''Note 1'':'''<br>Each section now contains the appropriate log directives | '''''Note 1'':'''<br>Each section now contains the appropriate log directives. Apache will automatically create the log files (in folder *\Uniform Server\udrive\usr\local\apache2\logs) when each site is accessed or when an error is produced. | ||
'''''Note 2'':'''<br>If Apache does not need to write to a file it is not created. | '''''Note 2'':'''<br>If Apache does not need to write to a file, it is not created. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Important notes == | == Important notes == | ||
'''''Note 1'':'''<br>The program automatically un-comments the line '''NameVirtualHost *''' | '''''Note 1'':'''<br>The program automatically un-comments the line '''NameVirtualHost *''' . If you have previously used virtual hosts and decide to run the server with no virtual hosts you must manually re-insert this comment. | ||
# Open file: '''httpd.conf''' | # Open file: '''httpd.conf''' | ||
Line 106: | Line 106: | ||
'''''Note 2'':'''<br>Not transportable | '''''Note 2'':'''<br>Not transportable | ||
When you have created your virtual hosts view your sites by typing the real web-site name into | When you have created your virtual hosts, view your sites by typing the real web-site name into your browser address bar. For example www.mpgautos.com will serve pages from the site1 folder. If you copy Uniform Server and your sites to a memory stick, do not be surprised if they no longer work when run on a different machine. You need to copy the Windows hosts entries to the machine you are running on. However if this is inconvenient then this link may help [[Virtual Hosting: PAC|Virtual Hosting & PAC]]. | ||
'''''Note 3'':'''<br>Common problems | '''''Note 3'':'''<br>Common problems | ||
*If you find the servers no longer run after creating a Vhost with separate logs make sure you have included a second parameter for the custom log. | *If you find the servers no longer run after creating a Vhost with separate logs, make sure you have included a second parameter for the custom log. | ||
*Make sure all file paths do not end with a forward slash. | *Make sure all file paths do not end with a forward slash. | ||
*Make sure the line NameVirtualHost * is uncommented. | *Make sure the line NameVirtualHost * is uncommented. |