標籤:
在弄到新伺服器,安裝了所有東西後,開始配置新的網站測試了,可是問題卻隨之而來呀,主要是網站設定成功,但是並不支援php。
nginx配置網站其實就是基於一ip多網站。
那麼在配置目錄中建立一個設定檔,名字起得和網站名字相同,然後寫入:
server { listen 80; server_name www.piyaoyan.com piyaoyan.com; access_log /var/log/nginx/piyaoyan.com/access.log main; root /home/akcms/domains/piyaoyan.com/www; index index.html index.htm index.php; rewrite ^/$ /akcms_item.php?id=1 last; rewrite ^/rss.xml$ /akcms_item.php?id=6 last; rewrite ^/index.html$ /akcms_item.php?id=1 last; rewrite ^/index-([0-9]+).htm$ /akcms_item.php?id=1&page=$1 last; rewrite ^/index-([0-9]+).html$ /akcms_item.php?id=1&page=$1 last; rewrite ^/yaoyan/([0-9]+).html$ /akcms_item.php?id=$1 last; rewrite ^/category/([0-9]+)\.html$ /akcms_category.php?id=$1 last; rewrite ^/category/([0-9]+)\-([0-9]+)\.html$ /akcms_category.php?id=$1&page=$2 last; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
在這個配置中寫了偽靜態規則,支援php是下面這一條location ~\.pjp$。
寫完配置後檢測nginx的配置是否正確,使用nginx -t 然後重啟nginx ,使用nginx -s reload
在瀏覽器中訪問,看看是否可以,是否支援php.
好,不支援,那麼這就要修改phpfastcgi的配置了,使用ps -ef | grep php
找到該服務,看看它的設定檔在什麼地方,然後編輯一下。
在這裡我們需要修改pool的使用者和組使用者,修改為和設定檔對應的使用者和組即可。
重啟這個玩意,重啟它有點麻煩,還得通過pid來重啟:kill -USR2 pid(就是主進程id)重啟該服務。
Linux下nginx配置虛擬機器主機