Linux下nginx配置虛擬機器主機

來源:互聯網
上載者:User

標籤:

在弄到新伺服器,安裝了所有東西後,開始配置新的網站測試了,可是問題卻隨之而來呀,主要是網站設定成功,但是並不支援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配置虛擬機器主機

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.