linux下nginx安裝php

來源:互聯網
上載者:User

標籤:pcntl   clu   nginx   ase   open   mbr   執行   freetype   reg   

把php安裝包上傳到linux的/usr/local/src

1.解壓

cd /usr/local/srctar zxvf php-5.6.9.tar.gzcd php-5.6.9

  

2.編譯安裝

./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar

  

錯誤1

configure: error: xml2-config not found. Please check your libxml2 installation. 配置:錯誤:xml2-config不見了。請檢查你的libxml2安裝。解決:yum install libxml2 libxml2-devel -y

  

錯誤2

configure: error: Cannot find OpenSSL’s <evp.h>配置:錯誤:找不到OpenSSL的< evp.h >解決:yum install openssl openssl-devel -y

  

錯誤3

Configure: error: Please reinstall the BZip2 distribution配置:錯誤:請重新安裝BZip2分布解決:yum install bzip2 bzip2-devel -y

  

錯誤4

configure: error: jpeglib.h not found.配置:錯誤:jpeglib。沒有找到。解決:yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y

  

錯誤5

Configure: error: mcrypt.h not found. Please reinstall libmcrypt.配置:錯誤:mcrypt。沒有找到。請重新安裝libmcrypt。解決:安裝epel-release源 yum install epel-release -yyum install libmcrypt-devel –y

  

最後最重要

makemake install

  

3.拷貝PHP主設定檔

 cp php.ini-production /usr/local/etc/php.ini
 

2、為php-fpm提供設定檔

cd /usr/local/phpcp etc/php-fpm.conf.default etc/php-fpm.confvim etc/php-fpm.conf

  

修改

user = www-datagroup = www-data

  

如果www-data使用者不存在,那麼先添加www-data使用者,命令列:

groupadd www-datauseradd -g www-data www-data

設定檔修改

pm.max_children = 150pm.start_servers = 8pm.min_spare_servers = 5pm.max_spare_servers = 10pid = /usr/local/php/var/run/php-fpm.pid 

  

3、啟動php-fpm

執行

/usr/local/php/sbin/php-fpm

使用如下命令來驗正(如果此命令輸出有中幾個php-fpm進程就說明啟動成功了):

ps aux | grep php-fpm

3、nginx和php-fpm整合

編輯/usr/local/nginx/nginx.conf

vim /usr/local/nginx/nginx.conf

修改如下:

紅框中“#”號去掉

 

 

紅框中“#”號去掉

 

 

添加紅框中內容

 

 

改成如下

location ~ \.php$ {            root         html;            fastcgi_pass 127.0.0.1:9000;            fastcgi_index index.php;            include        fastcgi.conf;}

 

 

重新載入nginx的設定檔:

 /usr/loca/nginx/sbin/nginx -s reload

  

4、測試php檔案

 在/usr/local/nginx/html下建立index.php檔案,輸入如下內容

<?php    phpinfo();?>

  

5、瀏覽器訪問

訪問http://你的伺服器ip/index.php,皆可以見到php資訊了。

 

 

 

參考:http://www.cnblogs.com/flywind/p/6019631.html (php-fpm)

 

linux下nginx安裝php

相關文章

聯繫我們

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