1. 程式人生 > >centos6.9 PHP的編譯安裝並連接nginx

centos6.9 PHP的編譯安裝並連接nginx

依賴關系 fault tro 目錄 服務器 libmcrypt user 安裝 mbr

1.安裝yum -y install libxml2-devel openssl-devel bzip2-devel libmcrypt-devel 解決php包的依賴關系,可能libmcrypt會報錯,先執行yum install epel-release,再重新安裝一下就可以了。

技術分享圖片

2.下載PHP安裝包並且上傳到服務器,解壓,(或者可以用wget直接下載到服務器)。

技術分享圖片

3.在PHP包的位置編譯php:

./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm --with-fpm-user=www \

--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo \
--enable-maintainer-zts

技術分享圖片

4.make && make install

技術分享圖片

5.復制相關配置文件到相關位置上:

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

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

技術分享圖片

技術分享圖片

技術分享圖片

6.加權限並設置開機啟動php

技術分享圖片

技術分享圖片

7.開啟php服務:

/usr/local/php/sbin/php-fpm或者 /etc/init.d/php-fpm start

技術分享圖片

8.查看php是否啟動成功:

netstat -lnt |grep 9000

技術分享圖片

9.建一個存放nginx日誌的文件與網站根目錄:

mkdir -p /tmp/www/feiyin.com

mkdir -p /tmp/www/feiyin.com

技術分享圖片

技術分享圖片

centos6.9 PHP的編譯安裝並連接nginx