一、變更apache的端口,方法如下
1.修改Apache監(jiān)聽處理動態(tài)請求端口
變更文件 /etc/apache2/sites-abailable/default 的端口
<VirtualHost *:8080>
......
</VirtualHost>
2.修改Apache監(jiān)聽端口
變更文件 /etc/apache2/ports.conf 的端口
NameVirtualHost *:8080Listen 80803.重啟apachesudo /etc/init.d/apache2 reload
sudo /etc/init.d/apache2 restart
如果修改后php還是無法解析,可以執(zhí)行如下操作試試sudo apt-get install phpmyadmin
然后重啟系統(tǒng)
此時可以通過http://localhost:8080進行訪問
二、設置nginx反向代理
將php文件的請求路由到由Apache做處理。Nginx 占用 80 端口,過濾靜態(tài)請求,然后動態(tài)請求即 Proxy 到 Apache 的 8080 端口。Proxy 反向代理的好處是訪問的時候,始終就是 80端口,來訪者不會覺察到有任何的區(qū)別。
變更文件/etc/nginx/sites-available/default,在server中添加如下代碼
server {
location ~* ^.*\.php$ {
#if (!-f $request_filename) {#return 404;#}proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $host;proxy_pass http://127.0.0.1:8080;}
}
修改完成后重啟nginx
sudo /etc/init.d/nginx restart