1、打开httpd.conf,查找Listen:80,在下面一行加入Listen:8080;
2、查找#Include conf/extra/httpd-vhosts.conf,将此行前面的#去掉;
3、打开httpd.conf文件目录下面的extra文件夹下面的httpd-vhosts.conf文件;
4、查找NameVirtualHost *:80,在下面一行增加NameVirtualHost *:8080;
5、复制httpd-vhosts.conf文件最下面的如下代码,并且在下面粘贴一份:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <VirtualHost *:80> ServerAdmin webmaster@dummy-host.abc.com DocumentRoot "G:\PHP" ServerName dummy-host.abc.com ServerAlias www.dummy-host.abc.ccom ErrorLog "logs/dummy-host.abc.com-error.log" CustomLog "logs/dummy-host.abc.com-access.log" common </VirtualHost>
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.abc.com DocumentRoot "G:\PHP" ServerName dummy-host2.abc.com ErrorLog "logs/dummy-host2.abc.com-error.log" CustomLog "logs/dummy-host2.abc.com-access.log" common </VirtualHost>
|
6、将上面代码修改为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <VirtualHost *:8080> ServerAdmin webmaster@dummy-host.abc.com DocumentRoot "G:\PHP\abc" ServerName dummy-host.abc.com ServerAlias www.dummy-host.abc.ccom ErrorLog "logs/dummy-host.abc.com-error.log" CustomLog "logs/dummy-host.abc.com-access.log" common </VirtualHost>
<VirtualHost *:8080> ServerAdmin webmaster@dummy-host2.abc.com DocumentRoot "G:\PHP\abc" ServerName dummy-host2.abc.com ErrorLog "logs/dummy-host2.abc.com-error.log" CustomLog "logs/dummy-host2.abc.com-access.log" common </VirtualHost>
|
7、保存并重启apache。
备注:
1、以上代码主要是修改了端口和目录,80端口对应的目录为G:\PHP,8080端口对应的目录为G:\PHP\abc;
2、新增加的端口对应的目录必须在Apache目录下面;
3、打开http://localhost:8080即可访问G:\PHP\abc目录。
下面是一些补充资料:
在我们想 配置多个虚拟机主机的时候 而且又想端口不一样的情况下 我在网上 找了很多 都是扯淡了…今天下午我就总结了一下午 终于把 多个端口的 apache 配置搞定了./
首先在http.conf 下面加个Include /etc/httpd/conf/51buyhost.conf 这句话 等会就知道了..呵呵
下面接着往下看…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| NameVirtualHost *:8080
Listen 8080 <VirtualHost *:8080> DocumentRoot "/var/www/html/goodfoison"
ServerName 192.168.0.50 ServerAlias 192.168.0.50 <Directory "/var/www/html/goodfoison"> allow from all Options +Indexes </Directory> </VirtualHost>
Listen 8081 <VirtualHost *:8081> DocumentRoot "/var/www/html/szlise"
ServerName 192.168.0.50 ServerAlias 192.168.0.50 <Directory "/var/www/html/szlise"> allow from all Options +Indexes </Directory> </VirtualHost>
|
以上内容适用于Linux系统