具体方法:
1、安装编译环境
考虑到自带的源有的组件没有,可以先安装epel第三方源
yum -y install epel-release yum -y install gcc automake autoconf libtool make gcc-c++ glibc libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libmcrypt mcrypt mhash php-mcrypt
2、下载php版本包
本次安装环境的版本包为php5.6
wget http://cn2.php.net/distributions/php-5.6.24.tar.gz tar zvxf php-5.6.24.tar.gz cd php-5.6.24
3、编译
php编译过程中,如果要php支持相应的功能,需要先安装对应的组件,然后再编译。
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-MySQL --with-mysqli make && make install
4、配置文件
复制配置文件,对其中一些代码进行修改,可根据需要开启php中的功能
cp php.ini-development /usr/local/php/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp sapi/fpm/php-fpm /usr/local/bin
修改php-fpm.conf配置文件,使用www用户和www用户组运行
vim /usr/local/php/etc/php-fpm.conf #修改为以下 ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = www group = www
修改php.ini,根据需求开启需要的php功能
vim /usr/local/php/php.ini ############################# display_errors = On display_startup_errors = On error_prepend_string = "<br><font color=#ff0000>" error_append_string = "</font><br><br>" fastcgi.impersonate = 1 date.timezone = asia/ShanghAI extension=php_mysql.dll extension=php_gd2.dll extension=php_mbstring.dll
5、运行
/usr/local/bin/php-fpm #查看是否运行 netstat -anop | grep php
出现以下界面表示正常运行: