ubuntu 13.04 nginx php 裝配

來源:互聯網
上載者:User
ubuntu 13.04 nginx php 安裝
之前一直摸索,百度好多文章,得出一個最簡單的安裝方法,但是不知道是否正確,或者有什麼遺漏的。

1.安裝nginx
sudo apt-get install nginx

2.安裝php
sudo apt-get install php5-fpm

3.配置nginx
sudo gedit /etc/nginx/sites-available/default

root /www;
index index.html index.htm index.php;

location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}

4.啟動nginx
sudo service nginx start

安裝完畢,現在有兩個問題,網上的很多文章都差不多,主要的差異在PHP安裝和nginx配置哪裡。

1.php是否只需要安裝php5-fpm即可?

2. location ~ \.php$ {
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
## With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
## With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_index index.php;
include fastcgi_params;
}
各行的配置分別代表什麼意思?

3.為什麼使用fastcgi_pass 127.0.0.1:9000;就無法啟動nginx?

分享到:


------解決方案--------------------
首先,我建議你用centsos來作為php的服務器系統,他比ubuntu更穩定,這一點你可以搜尋一下centos的歷史即可瞭解.
sudo apt-get install nginx
sudo是爲了提升權限 apt-get install是直接從ubuntu的鏡像取得安裝包安裝.
在centos裡的命令是 yum install nginx

在linux上搭建PHP環境非常麻煩,不過我建議下載lnmp這個組合環境,用這個組合環境安裝完畢之後再來設置nginx的線程數和fastcgi的一些高級設定,這一部份非常麻煩且重要,而且沒有固定設置方法可供你參考,很多東西都要自己嘗試摸索,因為每一台伺服器的硬體和效能不同,如果設置不好的話,你的網站會常常出現錯誤500或錯誤502
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.