环境:centos 6.4
php下载地址:http://php.net/downloads.php
php编译安装
极简编译参考:http://cn2.php.net/manual/zh/install.unix.nginx.php
安装php必须 安装的依赖
yum install libxml2 libxml2-devel bzip2-devel gmp-devel
yum -y install wget
cd /home
wget http://cn2.php.net/distributions/php-5.6.11.tar.gz
tar -zxvf php-5.6.11.tar.gz
cd php-5.6.11
#configure 核心参数参考:http://cn2.php.net/manual/zh/configure.about.php
'./configure' '--enable-fpm' '--with-mysqli' '--prefix=/usr/local/php5.6' '--with-config-file-path=/usr/local/php5.6/etc' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-openssl' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-kerberos' '--enable-shmop' '--enable-calendar' '--enable-xml' '--without-mysql' '--with-gd' '--disable-dom' '--disable-dba' '--without-unixODBC' '--enable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--with-sqlite3' '--disable-phar' '--disable-fileinfo' '--enable-json' '--without-pspell' '--disable-wddx' '--with-curl' '--disable-posix' '--disable-sysvmsg' '--disable-sysvshm' '--disable-sysvsem' '--with-mcrypt' '--with-pdo-mysql' '--with-jpeg-dir' '--with-png-dir' '--enable-gd-native-ttf' '--with-freetype-dir' '--enable-mbstring'
make && make install
cp php.ini-development /usr/local/php5.6/etc/php.ini
cd /usr/local/php5.6/etc
cp php-fpm.conf.default php-fpm.conf
cd ..
sbin/php-fpm -D
php-fpm: 开启和关闭
参数:
INT, TERM 立刻终止
QUIT 平滑终止
USR1 重新打开日志文件
USR2 平滑重载所有worker进程并重新载入配置和二进制模块
使用方法:
kill -INT/QUIT/USR1/USR2 进程号
编译扩展: mcrypt
下载地址: http://cn2.php.net/manual/zh/mcrypt.requirements.php
注意:安装php 的mcrypt 扩展只需要安装 libmcrypt
yum install libtool-ltdl-devel
./configure --disable-posix-threads --enable-dynamic-loading
make && make install
cd /home/php-5.6.11
./configure 其他一些扩展 --with-mcrypt
到这会报错:Don't know how to define struct flock on this system, set --enable-opcache=no
解决办法:
vi /etc/ld.so.conf.d/local.conf
加入 /usr/local/lib
ldconfig -v
make && make install
编译curl 扩展
yum -y install libcurl libcurl-devel
./configure 其他一些扩展 --with-curl
编译pdo_mysql扩展
yum -y install pdo_mysql
./configure 其他一些扩展 --with-pdo-mysql
编译GD库
yum -y install libjpeg-devel libpng-devel freetype-devel
./configure 其他一些扩展 --with-gd --with-jpeg-dir --with-png-dir --enable-gd-native-ttf --with-freetype-dir