1.安装PHP所有的依赖软件包
[root@web01 ~]# yum install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel openssl-devel -y
检查是否安装成功
[root@web01 ~]# rpm -qa zlib-devel libxml2-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel openssl-devel
安装yum无法安装的libiconv库
[root@web01 tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz[root@web01 tools]# tar zxf libiconv-1.14.tar.gz[root@web01 tools]# cd libiconv-1.14[root@web01 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv[root@web01 libiconv-1.14]# make && make install
添加阿里的epel.repo源(
yum源无法安装的支持库)libmcrypt-devel mhash mhash-devel mcrypt
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt
yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt
2. 编译安装PHP (php-5.5.32.tar.gz)
[root@web01 tools]# rz[root@web01 tools]# rz -y[root@web01 tools]# tar xf php-5.5.32.tar.gz[root@web01 tools]# cd php-5.5.32
3. 已安装玩mysql的情况下编译参数:
[root@web01 php-5.3.32]#./configure--prefix=/application/php5.5.32
--with-mysql=/application/mysql/
--with-iconv-dir=/usr/local/libiconv
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir=/usr
--enable-xml
--disable-rpath
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--with-curl
--enable-mbregex
--enable-fpm
--enable-mbstring
--with-mcrypt
--with-gd
--enable-gd-native-ttf
--with-openssl
--with-mhash
--enable-pcntl
--enable-sockets
--with-xmlrpc
--enable-zip
--enable-soap
--enable-short-tags
--enable-static
--with-xsl
--with-fpm-user=apache
--with-fpm-group=apache--enable-opcache=no
--enable-ftp
4.编译PHP软件过程
[root@web01 php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/[root@web01 php-5.5.32]# touch ext/phar/phar.phar[root@web01 php-5.5.32]# make #出现Bulit complete.
5.安装PHP生成文件到系统
[root@web01 php-5.5.32]# make install #Installing PDO headers:
6.配置PHP引擎配置文件php.ini
[root@web01 php-5.5.32]# ln -s /application/php5.5.32 /application/php[root@web01 php-5.5.32]# ll /application/phplrwxrwxrwx 1 root root 22 Aug 26 18:32 /application/php -> /application/php5.5.32[root@web01 php-5.5.32]# ls php.ini*php.ini-development php.ini-production #分别用于测试环境和生产环境[root@web01 php-5.5.32]# cp php.ini-production /application/php/lib/php.ini[root@web01 php-5.5.32]# ls -l /application/php/lib/php.ini-rw-r--r-- 1 root root 69266 Aug 26 18:33 /application/php/lib/php.ini
7.配置PHP服务(FastCGI方式)的配置文件php-fpm.conf
[root@web01 php-5.5.32]# cd /application/php/etc/[root@web01 etc]# lspear.conf php-fpm.conf.default[root@web01 etc]# cp php-fpm.conf.default php-fpm.conf #php-fpm.conf后续会有优化
8. 启动PHP服务(FastCGI方式)
[root@web01 etc]# /application/php/sbin/php-fpm[root@web01 etc]# ps -ef|grep php-fpmroot 13440 1 0 18:39 ? 00:00:00 php-fpm: master process (/application/php5.5.32/etc/php-fpm.conf)nginx 13441 13440 0 18:39 ? 00:00:00 php-fpm: pool wwwnginx 13442 13440 0 18:39 ? 00:00:00 php-fpm: pool wwwroot 13451 1724 0 18:40 pts/1 00:00:00 grep php-fpm[root@web01 etc]# lsof -i:9000COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEphp-fpm 13440 root 7u IPv4 184892 0t0 TCP localhost:cslistener (LISTEN)php-fpm 13441 nginx 0u IPv4 184892 0t0 TCP localhost:cslistener (LISTEN)php-fpm 13442 nginx 0u IPv4 184892 0t0 TCP localhost:cslistener (LISTEN)