安装PHP
安装前置
yum install libpng libjpeg freetype libmcrypt libmcrypt-devel libpng-devel libjpeg-devel freetype-devel libxml2 libxml2-devel libcurl libcurl-devel
下载解压
wget http://cn2.php.net/distributions/php-5.6.16.tar.gz
tar -zxvf php-5.6.16.tar.gz
编译安装
./configure --prefix=/usr/local/php \
--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 \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-mcrypt \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--enable-mbstring \
--enable-pdo \
--with-config-file-path=/etc
安装make && make install
配置php
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
sed -i '/listen = 127.0.0.1:9000/a\listen = /dev/shm/php-fpm.sock' /usr/local/php/etc/php-fpm.conf
sed -i 's/nobody/nginx/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/listen = 127.0.0.1/#&/' /usr/local/php/etc/php-fpm.conf
sed -i '/listen.mode = 0660/a\listen.mode = 0666' /usr/local/php/etc/php-fpm.conf
echo "./usr/local/php/sbin/php_fpm" >> /etc/rc.local
添加php-fpm开机启动脚本
#!/bin/bash # php-fpm startup script for the php-fpm # php-fpm version:5.5.0-alpha6 # chkconfig: - 85 15 # description: php-fpm is very good # processname: php-fpm # pidfile: /var/run/php-fpm.pid # config: /usr/local/php/etc/php-fpm.conf php_command= /usr/local/php/sbin/php-fom php_config= /usr/local/php/etc/php-fpm .conf php_pid= /usr/local/php/var/run/php-fpm .pid RETVAL=0 prog= "php-fpm" #start function php_fpm_start() { /usr/local/php/sbin/php-fpm } start(){ if [ -e $php_pid ] then echo "php-fpm already start..." exit 1 fi php_fpm_start } stop(){ if [ -e $php_pid ] then parent_pid=` cat $php_pid` all_pid=` ps -ef | grep php-fpm | awk '{if(' $parent_pid ' == $3){print $2}}' ` for pid in $all_pid do kill $pid done kill $parent_pid fi exit 1 } restart(){ stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $ "Usage: $prog {start|stop|restart|status}" exit 1 esac exit $RETVAL |
添加
chkconfig --add php-fpm
chkocnifg php-fpm on