首先下载源码包至本地目录,下载位置http:
# pwd
/usr/local/src
# tar -xf php-5.6.9.tar.gz
# cd ..
# ~ln -sv ./src/php-5.6.9 php~ ###说明:考虑编译后的简洁,此命令移除@20160729
# cd php/
# ./configure \ ###说明:编译的内容被调整@20160729
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir
###有关编译配置项的详细描述:https:
# make && make install
###以下为安装完毕之后的提示信息
Installing shared extensions:
/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP FPM binary: /usr/local/php/sbin/
Installing PHP FPM config: /usr/local/php/etc/
Installing PHP FPM man page: /usr/local/php/php/man/man8/
Installing PHP FPM status page: /usr/local/php/php/php/fpm/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1 ### Author : Leshami
page: php-config.1 ### Blog : http:
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.3.12
[PEAR] Console_Getopt - installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.3
[PEAR] PEAR - installed: 1.9.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/php/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
###php配置
php.ini是php运行核心配置文件
php-fpm.conf是php-fpm进程服务的配置文件
# 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
# chmod +x /etc/init.d/php-fpm
###fpm测试php配置
# /usr/local/php/sbin/php-fpm -t
[23-May-2016 20:03:52] NOTICE:
configuration file /usr/local/php/etc/php-fpm.conf test is successful
# chkconfig --add php-fpm
# chkconfig php-fpm on
# service php-fpm start
Starting php-fpm done
# ps -ef|grep php
root 45690 1 0 20:07 ? 00:00:00 php-fpm: master process(/usr/local/php/etc/php-fpm.conf)
nobody 45691 45690 0 20:07 ? 00:00:00 php-fpm: pool www
nobody 45692 45690 0 20:07 ? 00:00:00 php-fpm: pool www
root 45694 3441 0 20:07 pts/4 00:00:00 grep php
# netstat -nltp|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 45690/php-fpm