LNMP(nginx php-fpm mysql) 環境部署——php

來源:互聯網
上載者:User

標籤:php-fpm

前言:

之前已經說過部署的初衷,如有不清楚的,可以看下上篇的前言或在評論區留言給我。

此篇主要介紹安裝php,php會要用到mysql串連資料庫


準備:

php官網:php.net

源碼目錄:/usr/local/src

php採用源碼安裝方式

系統為:centos 6.8

php採用5.6版本。最新版本為7版本,如是新項目可採用7版本,對於老項目,如沒有重構的準備,建議不要升級到7


安裝:

1 安裝工具,配置編譯的時候提示缺少什麼就安裝什麼的開發包

yum install -y wget make gcc libxml2-devel opensll-devel bzip2-devel libcurl-devel gd-devel

2 下載源碼包及簽名檔案

wget wget http://cn2.php.net/distributions/php-5.6.28.tar.gz.asc

3 驗證檔案簽名,在沒有密鑰前驗證會給出鑰匙號並提示沒有公開金鑰

gpg --verify php-5.6.28.tar.gz.asc

4 下載密鑰

gpg --keyserver keys.gnupg.net --recv-key 33CFC8B3

5 再次驗證簽名

gpg --verify php-5.6.28.tar.gz.asc
gpg: Signature made Wed Nov  9 10:24:59 2016 CST using RSA key ID 33CFC8B3gpg: Good signature from "Ferenc Kovacs <[email protected]>"gpg: WARNING: This key is not certified with a trusted signature!gpg:          There is no indication that the signature belongs to the owner.Primary key fingerprint: 6E4F 6AB3 21FD C07F 2C33  2E3A C2BF 0BC4 33CF C8B3

注意:源碼包要和簽名檔案放到同一路徑下

看到 Good signature 既表明驗證成功,後面的警告是說簽名不受信任,這個要通過最後的密鑰指紋和簽名者驗證,http://php.net/downloads.php#gpg-5.6 官方給出了密鑰指紋


6 解壓

tar zxf php-5.6.28.tar.gzcd php-5.6.28.tar.gz


7 配置編譯參數

./configure --help./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-mysql --with-mysqli --with-config-file-scan-dir=/etc/php.d --enable-fpm --with-gd --with-iconv --with-zlib --enable-xml --enable-inline-optimization --with-openssl --enable-pcntl --enable-zip --with-curl --with-bz2 --with-jpeg-dir --with-png-dir --enable-mbstring

8 編譯

makemake install

9 配置php服務

cp php.ini-production /usr/local/php/etc/php.iniln -s /usr/local/php/etc/php.ini /etc/php.ini#拷貝模板檔案為php-fpm設定檔cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf ln -s /usr/local/php/etc/php-fpm.conf /etc/php.ini#添加啟動服務cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm chmod +x /etc/rc.d/init.d/php-fpmchkconfig php-fpm on

php-fpm 預設通過9000連接埠提供服務,需要添加iptables規則,允許web cgi請求php。

web叢集/反向 Proxyip段 172.16.10.0/24

iptables -I INPUT -s 172.16.10.0/24 -p tcp --dport 9000 -j ACCEPT


10 測試

echo ‘<?php phpinfo();?>‘ info.php/usr/local/php/bin/php -f info.php


11 啟動php-fpm服務

service php-fpm start



本文出自 “morrowind” 部落格,請務必保留此出處http://morrowind.blog.51cto.com/1181631/1875224

LNMP(nginx php-fpm mysql) 環境部署——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.