准备
-
下载: 下载 的文件
-
系统环境 根据需要的基本功能模块,需要准备以下软件
后yum更新
yum -y install autoconf automake libtool gcc gcc-c++ openssl openssl-devel
处理xml相关需要libxml2库
处理url相关需要curl库
处理图像相关需要freetype库
处理图像相关需要libjpeg库
处理图像相关需要libpng库
处理图像相关需要gd库
处理mcrypt需要 libmcrypt
安装
- install libxml
tar xzf libxml2-2.7.2.tar.gz cd libxml2-2.7.2 ./configure make && make install
- install freetype
tar xzf freetype-2.6.2.tar.gz cd freetype-2.6.2 ./configure make && make install
- install libjpeg
tar xzf jpegsrc.v9a.tar.gz cd jpeg-9a ./configure --enable-shared --enable-static make && make install
- install zlib
tar xzf zlib-1.2.8.tar.gz cd zlib-1.2.8 ./configure make && make install
- iinstall libpng
tar xzf libpng-1.6.12.tar.gz cd libpng-1.6.12 ./configure make && make install
- install libgd
tar xzf gd-2.0.35.tar.gz cd gd-2.0.35 ./configure --enable-shared make && make install
- install curl
tar xzf curl-7.37.1.tar.gz cd curl-7.37.1 ./configure make && make install
- install Libmcrypt
tar xzf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure make && make install
- install php
tar xzf php-5.5.30.tar.gz cd php-5.5.30 ./configure --enable-ctype --enable-exif --enable-ftp --with-curl --with-zlib --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --disable-debug --enable-sockets --disable-short-tags --enable-phar --enable-fpm --with-gd --with-openssl --with-mysql --with-mcrypt --enable-bcmath --with-iconv --enable-pcntl --enable-zip --enable-soap --enable-session --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local make && make install
cp php.ini-development /etc/php.inicp php-fpm.conf.default /usr/local/etc/php-fpm.conf
使用
1.设置为服务 保存以下代码到/etc/init.d/php-fpm
#! /bin/sh### BEGIN INIT INFO# Provides: php-fpm# Required-Start: $remote_fs $network# Required-Stop: $remote_fs $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: starts php-fpm# Description: starts the PHP FastCGI Process Manager daemon### END INIT INFOprefix=/usr/localexec_prefix=${prefix}php_fpm_BIN=${exec_prefix}/sbin/php-fpmphp_fpm_CONF=${prefix}/etc/php-fpm.confphp_fpm_PID=/tmp/php-fpm.pidphp_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done}case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status}" exit 1 ;;esac
2.设置为自启动
chmod 775 /etc/rc.d/init.d/php-fpm #赋予文件执行权限chkconfig php-fpm on #设置开机启动service php-fpm restart #启动服务
以上是php的基本安装过程,下期介绍