Difference between revisions of "Apache Virtualhost Windows Xampp"
From MS Computech
Line 1: | Line 1: | ||
− | | + | |
===== วิธีการทำ Virtual Host บน Apache Windows ===== | ===== วิธีการทำ Virtual Host บน Apache Windows ===== | ||
− | | + | |
1> EditC:\WINDOWS\system32\drivers\etc\hosts | 1> EditC:\WINDOWS\system32\drivers\etc\hosts | ||
Line 10: | Line 10: | ||
127.0.0.1 host2.com | 127.0.0.1 host2.com | ||
127.0.0.1 host3.com | 127.0.0.1 host3.com | ||
− | </pre> | + | </pre> |
− | <br> | + | <br> |
2> edit extra\httpd-vhost.conf | 2> edit extra\httpd-vhost.conf | ||
Line 57: | Line 57: | ||
<VirtualHost xx.xx.xx.xx:80> | <VirtualHost xx.xx.xx.xx:80> | ||
ServerAdmin [email protected] | ServerAdmin [email protected] | ||
− | ServerName | + | ServerName mscompute.com |
− | ServerAlias | + | ServerAlias www.mscompute.com |
Indexes + Directory Root. | Indexes + Directory Root. | ||
DirectoryIndex index.html index.php index.htm | DirectoryIndex index.html index.php index.htm | ||
Line 78: | Line 78: | ||
<VirtualHost xx.xx.xx.xx:80> | <VirtualHost xx.xx.xx.xx:80> | ||
ServerAdmin [mailto:[email protected] [email protected]] | ServerAdmin [mailto:[email protected] [email protected]] | ||
− | ServerName | + | ServerName host.com |
− | ServerAlias | + | ServerAlias .www.host.com |
Indexes + Directory Root. | Indexes + Directory Root. | ||
DirectoryIndex index.html index.php index.htm | DirectoryIndex index.html index.php index.htm | ||
Line 97: | Line 97: | ||
<VirtualHost xx.xx.xx.xx:80> | <VirtualHost xx.xx.xx.xx:80> | ||
ServerAdmin [email protected] | ServerAdmin [email protected] | ||
− | ServerName | + | ServerName host2.com |
− | ServerAlias | + | ServerAlias www.host2.com |
Indexes + Directory Root. | Indexes + Directory Root. | ||
DirectoryIndex index.html index.php index.htm | DirectoryIndex index.html index.php index.htm | ||
Line 117: | Line 117: | ||
<VirtualHost xx.xx.xx.xx:80> | <VirtualHost xx.xx.xx.xx:80> | ||
ServerAdmin [email protected] | ServerAdmin [email protected] | ||
− | ServerName | + | ServerName host3.com |
− | ServerAlias | + | ServerAlias www.host3.com |
Indexes + Directory Root. | Indexes + Directory Root. | ||
DirectoryIndex index.html index.php index.htm | DirectoryIndex index.html index.php index.htm | ||
Line 132: | Line 132: | ||
</VirtualHost> | </VirtualHost> | ||
− | </pre> | + | </pre> |
− | + | <br> 3> Restart Apache | |
− | |||
− | 3> Restart Apache |
Revision as of 13:24, 6 December 2008
วิธีการทำ Virtual Host บน Apache Windows
1> EditC:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 host.com 127.0.0.1 host1.com 127.0.0.1 host2.com 127.0.0.1 host3.com
2> edit extra\httpd-vhost.conf
# # Virtual Hosts # # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.2/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # Use name-based virtual hosting. # NameVirtualHost xx.xx.xx.xx:80 # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # ##<VirtualHost *:80> ## ServerAdmin [email protected] ## DocumentRoot /www/docs/dummy-host.example.com ## ServerName dummy-host.example.com ## ServerAlias www.dummy-host.example.com ## ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log ## CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common ##</VirtualHost><VirtualHost *:80> ## ServerAdmin [email protected] ## DocumentRoot /www/docs/dummy-host2.example.com ## ServerName dummy-host2.example.com ## ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log ## CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common ##</VirtualHost> # Virtual Host # MSCOMPUTE.COM <VirtualHost xx.xx.xx.xx:80> ServerAdmin [email protected] ServerName mscompute.com ServerAlias www.mscompute.com Indexes + Directory Root. DirectoryIndex index.html index.php index.htm DocumentRoot C:/xampp/htdocs/host/htdocs CGI Directory ScriptAlias /cgi-bin/ C:/xampp/htdocs/host/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> # Logfiles ErrorLog C:/xampp/htdocs/host/logs/error.log CustomLog C:/xampp/htdocs/host/logs/access.log combined </VirtualHost> #============================================================ #host1.com >> Redirect # <VirtualHost xx.xx.xx.xx:80> ServerAdmin [mailto:[email protected] [email protected]] ServerName host.com ServerAlias .www.host.com Indexes + Directory Root. DirectoryIndex index.html index.php index.htm DocumentRoot C:/xampp/htdocs/host1/htdocs/ CGI Directory ScriptAlias /cgi-bin/ C:/xampp/htdocs/host1/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> # Logfiles ErrorLog C:/xampp/htdocs/host1/logs/error.log CustomLog C:/xampp/htdocs/host1/logs/access.log combined </VirtualHost> #================================================================ # host2.com <VirtualHost xx.xx.xx.xx:80> ServerAdmin [email protected] ServerName host2.com ServerAlias www.host2.com Indexes + Directory Root. DirectoryIndex index.html index.php index.htm DocumentRoot C:/xampp/htdocs/host2/htdocs CGI Directory ScriptAlias /cgi-bin/ C:/xampp/htdocs/host2/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> # Logfiles ErrorLog C:/xampp/htdocs/rapid4dl/logs/error.log CustomLog C:/xampp/htdocs/rapid4dl/logs/access.log combined </VirtualHost> #======================================================= # host3.com <VirtualHost xx.xx.xx.xx:80> ServerAdmin [email protected] ServerName host3.com ServerAlias www.host3.com Indexes + Directory Root. DirectoryIndex index.html index.php index.htm DocumentRoot C:/xampp/htdocs/host3/htdocs/ CGI Directory ScriptAlias /cgi-bin/ C:/xampp/htdocs/host3/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> # Logfiles ErrorLog C:/xampp/htdocs/host3/logs/error.log CustomLog C:/xampp/htdocs/host3/logs/access.log combined </VirtualHost>
3> Restart Apache