编译安装php7
解压安装
# tar zxvf php-7.0.2.tar.gz
# cd php-7.0.2
首先查看安装帮助
# ./configure --help
# ./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
如果有报错,用yum安装相应依赖包
例如:
# yum -y install curl-devel
# yum -y install libxslt-devel
编译安装
# make && make install
安装完成后,我们要把源码包中的配置文件复制到PHP安装目录下,源码包中有两个配置 php.ini-development php.ini-production ,看名字就知道,一个是开发环境,一个是生产环境,我们这里就复制开发环境的
cp
php.ini-development
/usr/local/php/lib/php
.ini
另外还需要设置环境变量 :修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
PATH=$PATH:
/usr/local/php/bin
export
PATH
然后执行生效命令
source
/etc/profile
查看PHP版本信息
php -
v
配置PHP-fpm
cp
/usr/local/php/etc/php-fpm
.conf.default
/usr/local/php/etc/php-fpm
.conf
cp
/usr/local/php/etc/php-fpm
.d
/www
.conf.default
/usr/local/php/etc/php-fpm
.d
/www
.conf
cp
/usr/src/php-7
.0.2
/sapi/fpm/init
.d.php-fpm
/etc/init
.d
/php-fpm
chmod
+x
/etc/init
.d
/php-fpm
启动php-fpm:
/etc/init
.d
/php-fpm
start