Linux下配置Apache为多端口,linuxapache


1、打开Apache的配置文件httpd.conf,在Listen 80处另起一行输入Listen 8080(监听8080端口),要想再添加端口可依次添加

2、在httpd.conf文件最后一行添加:注:默认的80路径为/var/www/html/,我这是在这个下面的文件夹下添加test文件夹为测试

NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName localhost:8080
DocumentRoot "/var/www/html/test/″
<Directory "/var/www/html/test/">
    Options FollowSymLinks IncludesNOEXEC
    AllowOverride All
    Order Deny,Allow
    Allow from all
</Directory>
</VirtualHost>
3、重启Apache:# service iptables restart
4、把8080(监听的端口)开放防火墙
ok,就这么简单 大功告成

----------------------------------------------------------------------------
后面发现还有更方便的方法
1、# cd /etc/httpd/conf.d/
在这个文件夹下新建 .conf文件 --自己命名.conf
写入内容如下:

Listen 83
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot /var/www/html/test
ServerName localhost:8080

AddDefaultCharset UTF-8

</VirtualHost>

然后保存 重启httpd服务,开放端口防火墙就可以了。

相关内容