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文件最下面的如下代码,并且在下面粘贴一份:
复制代码 代码如下:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G:PHP"
ServerName dummy-host.abc.com
Server
alias 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、将上面代码修改为:
复制代码 代码如下:
<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G:PHPabc"
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:PHPabc"
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:PHPabc;
2、新增加的端口对应的目录必须在Apache目录下面;
3、打开http://localhost:8080即可访问G:PHPabc目录。