PHP官网下载地址
wget http://cn2.php.net/get/php-7.0.7.tar.bz2/from/this/mirror/php-7.0.7.tar.bz2
安装相应的组件库,可根据需求更改
yum -y install 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 yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
进入安装目录进行编译安装,指向php安装路径,mysql和apache模块存在路径
tar xvf php-7.0.7.tar.bz2./configure --prefix=/usr/local/php7 \--with-apxs2=/usr/local/apache2/bin/apxs \--enable-mbstring \--enable-sockets \--with-config-file-path=/usr/local/php/etc \--enable-mysqlnd \--with-mysqli \--with-mysql \--with-pdo-mysql \--enable-fpm \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache \make && make install
拷贝模版配置文件
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.confcp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
修改进程默认用户
vim /usr/local/php7/etc/php-fpm.d/www.comf#将user和group更改为设置的网站管理用户
编辑apache的http.conf配置文件加入php支持
#文档内搜索'AddType'依次加入AddType application/x-httpd-php .php
启用php服务并加入开机自启
/usr/local/php7/sbin/php-fpmecho '/usr/local/php7/sbin/php-fpm' >> /etc/rc.local
届时就可以用apache建立PHP测试页<?php phpinfo();?>进行测试了