天天看點

LNMP—PHP的編譯安裝

    還需要注意一個問題,那就是我們單獨配置LNMP的思路是不對的,我們的思路應該也必須是LAMP+Nginx,即LANMP;而我們想當然會認為LNMP+Apache也行,但是這樣的的思路是錯誤的,這一點需要注意一下。

    下面直接進入LNMP的PHP編譯:

[root@LnmpLinux support-files]# cd /usr/local/src

    下載下傳

[root@LnmpLinux src]# wget http://cn2.php.net/distributions/php-5.6.12.tar.bz2

    解壓

[root@LnmpLinux src]# tar jxvf php-5.6.12.tar.bz2

    建立使用者

[root@LnmpLinux src]# useradd -s /sbin/nologin php-fpm

    進入php目錄編譯

[root@LnmpLinux src]# cd php-5.6.12

[root@LnmpLinux php-5.6.12]# ./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl

我們應該注意的問題:

    在上面編譯安裝過程中,有兩行用“紅字”标示出來,如下所示:

   --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc

因為我們是在LAMP的基礎上,進行LNMP的編譯安裝,LAMP中已經編譯過PHP了,是以我們要對LNMP中的PHP的目錄做一下更改,及上面編譯指令中的綠字部分,有利于我們區分開來,對于此點更改下文中均會以“綠字”标示出來。

安裝過程中出現的問題解決方法:

問題一:

    configure: error: jpeglib.h not found.

    [root@LnmpLinux php-5.6.12]# yum list |grep jpeg

    [root@LnmpLinux php-5.6.12]# yum install -y libjpeg-turbo-devel

    重新編譯安裝

問題二:

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.

    需安裝epel

    [root@LnmpLinux php-5.6.12]# rpm -ivh 'http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm'

    [root@LnmpLinux php-5.6.12]# yum list |grep mcry

    [root@LnmpLinux php-5.6.12]# yum install -y libmcrypt-devel

[root@LnmpLinux php-5.6.12]# make && make install

[root@LnmpLinux php-5.6.12]# echo $?

制作php全局配置檔案

[root@LnmpLinux php-5.6.12]# cp php.ini-production /usr/local/php2/etc/php.ini

制作啟動腳本

[root@LnmpLinux php-5.6.12]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

授予啟動腳本權限

[root@LnmpLinux php-5.6.12]# chmod 755 /etc/init.d/php-fpm

加入啟動程序

[root@LnmpLinux php-5.6.12]# chkconfig --add php-fpm

開機自動啟動

[root@LnmpLinux php-5.6.12]# chkconfig php-fpm on

設定php-fpm的配置檔案

[root@LnmpLinux php-5.6.12]# cd /usr/local/php2/etc

[root@LnmpLinux etc]# mv  php-fpm.conf.default  php-fpm.conf

檢查有無文法錯誤

[root@LnmpLinux etc]# /usr/local/php2/sbin/php-fpm -t

啟動服務

[root@LnmpLinux etc]# service php-fpm start

檢視程序

[root@LnmpLinux etc]# ps aux |grep php-fpm

監聽端口

[root@LnmpLinux etc]# netstat -lnp |grep php-fpm

本文轉自 聽丶飛鳥說 51CTO部落格,原文連結:http://blog.51cto.com/286577399/1683332