centos7.0 64位系统 安装PHP 支持 nginx

1  安装PHP所需要的扩展

                     yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel  gd gd-devel 

2 安装PHP(只支持nginx 不支持apache)

                   tar -jxvf php-5.3.27.tar.bz2
cd php-5.3.27
./configure --prefix=/usr/local/php5.3 --disable-debug --enable-shared --enable-fpm --with-fpm-user=www --with-fpm-group=www  --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-libxml-dir --with-openssl --with-bz2 --with-mcrypt  --enable-gd-native-ttf --with-curl --with-zlib-dir -with-gettext --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv --with-config-file-path=/usr/local/php5.3/etc --enable-mbstring --with-gd --disable-debug  --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets --with-mhash --enable-zip              make
make install
cp php.ini-production /usr/local/php5.3/etc/php.ini

设置 /usr/local/php/etc/php-fpm.conf 里面的内容 根据实际情况修改

vi /etc/init.d/php-fpm  (内容可以根据实际情况修改)

#!/bin/bash
# chkconfig:
# description: php-fpm is a FastCGI web server.
# processname: php-fpm
# config: /usr/local/php/etc/php-fpm.conf
# pidfile: /var/run/php-fpm.pid
#=======================================================================================
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin BINFILE="/usr/local/php/sbin/php-fpm"
CFGFILE="/usr/local/php/etc/php-fpm.conf"
PIDFILE="/var/run/php-fpm.pid"
LOCKFILE="/var/lock/php-fpm.lock" RETVAL= start() {
[[ -x $BINFILE ]] || exit
[[ -f $CFGFILE ]] || exit if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -gt ]]; then
echo "The php-fpm is already running."
return
fi $BINFILE -t >/dev/null >& if [[ $? -ne ]]; then
echo "The php-fpm configure has error."
return
fi echo -n "Starting php-fpm......"
$BINFILE -y $CFGFILE -g ${PIDFILE}
RETVAL=$?
echo
[[ $RETVAL -eq ]] && touch $LOCKFILE return $RETVAL
} stop() {
if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq ]]; then
echo "The php-fpm is not running."
return
fi echo -n "Shutting down php-fpm......" if [[ -f $PIDFILE ]]; then
kill -QUIT `cat ${PIDFILE}`
else
kill -QUIT `ps aux | grep php-fpm | awk '/master/{print $2}'`
fi RETVAL=$?
echo
[[ $RETVAL -eq ]] && rm -f $LOCKFILE $PIDFILE return $RETVAL
} restart() {
stop
sleep while true
do
if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq ]]; then
start
break
fi
sleep
done RETVAL=$?
echo return $RETVAL
} reload() {
if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq ]]; then
echo "The php-fpm is not running."
return
fi echo -n $"Reloading php-fpm......" if [[ -f $PIDFILE ]]; then
kill -USR2 `cat ${PIDFILE}`
else
kill -USR2 `ps aux | grep php-fpm | awk '/master/{print $2}'`
fi RETVAL=$?
echo return $RETVAL
} case "$1" in
start)
start
;; stop)
stop
;; restart)
restart
;; reload)
reload
;; *)
echo "Usage: service php-fpm {start|stop|restart|reload}"
RETVAL=
esac exit $RETVAL

设置php-fpm开机启动

       chmod  /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
/etc/init.d/php-fpm start

接下来就是配置 nginx支持php文件的访问

上一篇:WP7/WP8/WP8.1设置存储的区别


下一篇:iOS网络图片缓存详解