1、打開Apache的配置文件httpd.conf,在Listen 80處另起一行輸入Listen 8080(監聽8080端口),要想再添加端口可依次添加
2、在httpd.conf文件最后一行添加:注:默認的80路徑為/var/www/html/,我這是在這個下面的文件夾下添加test文件夾為測試
NameVirtualHost*:8080<VirtualHost*:8080>ServerNamelocalhost:8080DocumentRoot"/var/www/html/test/&PRime;
<Directory"/var/www/html/test/">
OptionsFollowSymLinksIncludesNOEXECAllowOverrideAllOrderDeny,AllowAllowfromall</Directory>
</VirtualHost>3、重啟Apache:# service iptables restart4、把8080(監聽的端口)開放防火墻ok,就這么簡單 大功告成----------------------------------------------------------------------------后面發現還有更方便的方法1、# cd /etc/httpd/conf.d/ 在這個文件夾下新建 .conf文件 --自己命名.conf寫入內容如下:
Listen 8080NameVirtualHost *:8080<VirtualHost *:8080> DocumentRoot /var/www/html/test ServerNamelocalhost:8080
AddDefaultCharset UTF-8
</VirtualHost>
然后保存 重啟httpd服務,開放端口防火墻就可以了。
新聞熱點
疑難解答