ubuntu下nginx+php5的部署

來源:互聯網
上載者:User

標籤:service   添加   ssl   static   gzip   adl   zip   down   pcr   

 

ubuntu下nginx+php5環境的部署和centos系統下的部署稍有不同,廢話不多說,以下為操作記錄:
1)nginx安裝
[email protected]:~# sudo apt-get update && sudo apt-get upgrade
[email protected]:~# sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev libssl-dev build-essential openssl libssl0.9.8 libssl-dev
[email protected]:~# wget http://nginx.org/download/nginx-1.8.0.tar.gz
[email protected]:~# tar -zxvf nginx-1.8.0.tar.gz
[email protected]:~# cd nginx-1.8.0
[email protected]:~# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
[email protected]:~# make && make install

2)php5的安裝
add-apt-repository 命令是 apt 源的添加,ppa 就是軟體對應的源,在官網上可以找到
[email protected]:~# sudo add-apt-repository ppa:ondrej/php5-5.6

如果上面命令執行後報錯和沒有發現命令則執行
[email protected]:~# sudo apt-get install Python-software-properties
[email protected]:~# sudo apt-get update
[email protected]:~# sudo apt-get install php
[email protected]:~# php5 -v

安裝好php後,在nginx裡添加對接php的配置後,訪問.php檔案會報錯502!
這是因為nginx中訪問.php檔案的請求都交給php-fpm程式處理的,php-fpm監聽9000連接埠
所以還有啟動php-fpm程式。

安裝php-fpm
[email protected]:~# apt-get install php5-fpm php5-gd php5-cli php5-curl php5-mcrypt php5-mysql php5-readline

啟動php-fpm
[email protected]:~# service php5-fpm start
[email protected]:~# ps -ef|grep php5-fpm
[email protected]:~# lsof -i:9000

但是發現php5-fpm啟動後,9000連接埠卻沒有起來!這是為什嗎?
這是因為php-fpm有兩種監聽方式:一種是.sock檔案方式,另一種是9000連接埠方式
修改辦法:
roo[email protected]:~# vim /etc/php5/fpm/pool.d/www.conf
.....
;listen = /var/run/php5-fpm.sock               //注釋這行,這是預設的監聽方式
listen = 9000                                            //改為監聽9000連接埠方式

重啟php-fpm
[email protected]:~# service php5-fpm restart
[email protected]:~# lsof -i:9000        //發現9000連接埠已經起來了

 

ubuntu下nginx+php5的部署

聯繫我們

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