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 8080
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot /var/www/html/test
ServerName localhost:8080
AddDefaultCharset UTF-8
</VirtualHost>
然后保存 重啟httpd服務,開放端口防火牆就可以了。