#由于是多 IP listens to the same port so write this
| The code is as follows |
Copy Code |
Listen 80 #若是多ip Multi-Port is #Listen 192.170.2.1:80 #Listen 192.170.2.5:8000 #由于使用多ip Namevirtualhost This setting Namevirtualhost 1.2.3.4:80 Namevirtualhost 5.6.7.8:80 #第一个ip给域名www. 111cn.net documentroot/www/111cn.net/ ServerName www.111cn.net Serveralias 111cn.net #第二个ip给域名www. sjolzy.com Documentroot/www/sjolzy.com ServerName www.sjolzy.com Serveralias sjolzy.com |
Set Apache virtual Host under Window
First, modify the Hosts file's domain name access method. Add a domain name point to
Different versions of Windows are in different locations,
| The code is as follows |
Copy Code |
Windows 3.1/95/98/me: C:\windows\hosts Windows nt/2000/xp Pro: C:\winnt\system32\drivers\etc\hosts or C:\windows\system32\drivers\etc\hosts Windows XP Home: C:\windows\system32\drivers\etc\hosts Windows Vista: C:\Windows\System32\Drivers\etc\hosts |
Open Hosts file, generally have ' 127.0.0.1 localhost ', add the domain name you want to increase, such as ' 127.0.0.1 Sjolzy ', the left is IP, the right is the domain name. In this way, the local access to http://sjolzy/(nonexistent domain name) is just as http://localhost points to the set site directory.
Next, on the Apache configuration file, create the corresponding virtual host.
Open the httpd.conf file and add the following
| The code is as follows |
Copy Code |
<virtualhost *:80> DocumentRoot "D:/www/sjolzy" ServerName Sjolzy </VirtualHost>
|
This allows the browser to enter the Http://sjolzy directly to the corresponding virtual host.
or refer to the following:
To implement the Apache virtual host method One:
To open a virtual host configuration file
To set the httpd.conf:
1. Note the following three lines
| The code is as follows |
Copy Code |
#ServerAdmin #ServerName #DocumentRoot |
2. Remove notes from mod_proxy.so and mod_proxy_ajp.so
3. #Virtual hosts
#Include conf/extra/httpd-vhosts.conf (Find this line, remove the front #)
/conf/extra/httpd-vhosts.conf
4. Open/conf/extra/httpd-vhosts.conf
#192.168.1.24 for local IP
Namevirtualhost 192.168.1.24:80
# PHP Project
| The code is as follows |
Copy Code |
<virtualhost 192.168.1.24:80> <directory "D:/phproot/phpmyadmin" > DirectoryIndex index.php </Directory> ServerAdmin Baibiao @gmail. com ServerName email.sinoepiboly.com #ServerAlias email.sinoepiboly.com DocumentRoot D:/phproot/phpmyadmin </VirtualHost> |
==================================================================
Method Two:
Two level domain name host development environment setting description
First step DNS resolution implementation
Locate the native host file, typically in C:\WINNT\system32\drivers\etc, and add at the end of the file:
| The code is as follows |
Copy Code |
127.0.0.1 localhost 127.0.0.1 www.com.cn 127.0.0.1 signup.com.cn 192.168.6.153 i.com.cn 192.168.6.153 x.com.cn |
which
| The code is as follows |
Copy Code |
192.168.6.2 i.com.cn 192.168.6.2 x.com.cn
|
The technician does not make the modification, is the art page specialized
Step Two: Apache settings
Open httpd.conf, take music.com.cn for example, other columns like add, at the end of the file add:
1. Ensure
Listen 80
2. Open comments
Namevirtualhost *:80
3. Add at the end
| The code is as follows |
Copy Code |
<virtualhost *:80> ServerAdmin x_cn@msn.com DocumentRoot "C:/Program Files/apache group/apache2/htdocs/espace/music" ServerName music.com.cn </VirtualHost> <virtualhost *:80> ServerAdmin x_cn@msn.com DocumentRoot "C:/Program Files/apache group/apache2/htdocs/espace/blog" ServerName blog.com.cn </VirtualHost> ... |
Restart, the Apache virtual host setup is complete.