getenforce setenforce 0 開機不自啟的配置如下:執行:vi /etc/selinux/config將SELINUX=xxxx 修改為SELINUX=disabledsystemctl status firewalld systemctl enable firewalldyum -y install nginx httpd phpvim /etc/httpd/conf/httpd.conf#Listen 85 #默認80,這裡為了不和nginx衝突,需另起一個#systemctl start httpd systemctl enable httpd netstat -anp|grep httpdvim /etc/nginx/nginx.conf刪除默認的80埠server cd /etc/nginx/conf.dvim pass.conf server { listen 80; location / { proxy_pass http://127.0.0.1:85; }}nginx –t #必要步驟,錯誤檢驗,無問題可做下一步systemctl restart nginx #重啟nginxsystemctl enable nginx #設置nginx開機自啟動netstat -anp|grep nginx #查看nginx埠是否存活firewall-cmd --add-port=80/tcp #防火牆開放80埠firewall-cmd --add-port=80/tcp --permanent #設置防火牆上開放的80埠永久生效echo "" > /var/www/html/index.phpmkdir /nginx echo "奔跑的烏拉拉" > /nginx/index.html
vim /etc/nginx/conf.d/pass.conf server { listen 80; location ~* \.php$ { proxy_pass http://127.0.0.1:85; } location / { root /nginx; }}nginx –t systemctl restart nginxIP/index.htmlIP/index.php
location /admin { proxy_pass http://www.test.com/; proxy_pass http://www.test.com; }請求的url 是http://www.test.com/admin/a.html如果代理方式是 proxy_pass http://www.test.com/; 那麼去www.test.com的根目錄下找a.html,/代表完全代理。如果代理方式是 proxy_pass http://www.test.com; 那麼去www.test.com的根目錄下的admin找a.html如果location中使用了模式匹配(正則),那麼,location中的url會直接補充到代理節點的後面.location ~ \.php$ { proxy_pass http://www.test.com; [正則表達式proxy_pass轉發的地址後面什麼都不能加] <<< 正確寫法 proxy_pass http://www.test.com:80; <<< 正確寫法 proxy_pass http://www.test.com/; <<< 錯誤寫法 proxy_pass http://www.test.com/img; <<< 錯誤寫法 } 此時,如果請求的url是 http://www.baidu.com/book/stu/a.php ,就會代理成 http://www.test.com/book/stu/a.php在location中如果有重定向的話,那麼就用重定向後的uri替換掉代理節點中的urilocation / { rewrite /(.*)$ /index.php?name=$1 break; proxy_pass http://www.baidu.com:80/img; } 此時,如果請求的url是 http://www.test.com/bajie ,就會代理成 www.baidu.com/index.php?name=bajie