# 安装 PHP
# 安装PHP基础环境
# PHP 配置文件:/usr/local/php/etc/php.ini
# PHP-FPM 配置文件:/usr/local/php/etc/php-fpm.conf
# 服务控制:service php-fpm (start|stop|restart|reload)
# 安装PHP依赖库
cd /usr/local/src
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7/
./configure
make
make install
cd libltdl/
./configure --enable-ltdl-install
make
make install
yum install mysql-devel
ln -s /usr/lib64/libXpm.so* /usr/lib/
mkdir /usr/lib/mysql
ln -s /usr/lib64/mysql/libmysqlclient* /usr/lib/mysql
# 安装PHP
#wget http://tw1.php.net/get/php-5.4.26.tar.gz/from/this/mirror
#tar zxf php-5.4.26.tar.gz
#cd php-5.4.26
# 下载src
wget http://tw1.php.net/get/php-5.6.21.tar.gz/from/this/mirror
mv mirror php-5.6.21.tar.gz
# 解压
tar zxf php-5.6.21.tar.gz
cd php-5.6.21
# 配置参数
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-libxml-dir \
--with-pcre-dir \
--with-mcrypt \
--with-openssl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-gettext \
--with-freetype-dir \
--with-bz2 \
--with-iconv-dir \
--with-zlib \
--with-zlib-dir \
--with-curl \
--with-xmlrpc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-icu-dir=/usr \
--enable-pcntl \
--enable-intl \
--enable-sockets \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-zip \
--enable-calendar \
--enable-mbstring \
--enable-exif \
--enable-soap \
--enable-wddx \
--enable-bcmath \
--enable-fd-setsize=4096 \
--disable-short-tags \
--disable-ipv6
# 编译
make
# 安装
make install
# 创建配置文件
#cp /usr/local/src/php-5.4.26/php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/src/php-5.6.21/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
# 创建 php 运行所需要目录并设置权限
mkdir /var/run/php
mkdir /var/log/php
chown -R www:www /var/run/php/
chown -R www:www /var/log/php/
# 设置 php-fpm 配置,修改以下参数项。
# vim /usr/local/php/etc/php-fpm.conf
pid = /var/run/php/php-fpm.pid
error_log = /var/log/php/error.log
user = www
group = www
listen = 127.0.0.1:9000
pm = static
# php-fpm 加入系统服务并开机启动
#cp /usr/local/src/php-5.4.26/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/src/php-5.6.21/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# vim /etc/init.d/php-fpm
#php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_fpm_PID=/var/run/php/php-fpm.pid
# 编辑 PHP 相关路径(/etc/init.d/php-fpm)
chmod u+x /etc/init.d/php-fpm
chkconfig --add php-fpm
service php-fpm start
chkconfig php-fpm on