准备环境
mkdir -p /data/conf/PHP7
mkdir -p /data/logs/PHP7
mkdir -p /root/software
1、下载编译工具
yum groupinstall 'Development Tools'
2、安装依赖包
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel
3、下载安装包并解压
cd /root/software
wget http://php.net/distributions/php-7.1.0.tar.gz
mkdir /root/software/php7 -p
tar -zxvf php-7.1.0.tar.gz -C /root/software/php7 --strip-components=1
cd /root/software/php7
4、编译安装
./configure --prefix=/usr/local/php7 --sysconfdir=/data/conf/php7 --with-config-file-path=/data/conf/php7 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache
make && make install
5、查看版本
/usr/local/php7/bin/php -v
6、添加环境变量
vim /etc/profile
在最后添加
####PHP####
PATH=$PATH:/usr/local/php7/bin
export PATH
source /etc/profile
8、配置php-fpm
cp php.ini-production /data/conf/php7/php.ini
cp /data/conf/php7/php-fpm.conf.default /data/conf/php7/php-fpm.conf
cp /data/conf/php7/php-fpm.d/www.conf.default /data/conf/php7/php-fpm.d/www.conf
9、设置启动关闭
cp /root/software/php7/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
service php-fpm start #启动
service php-fpm stop #停止
service php-fpm restart #重启
10、检查程序端口是否启动
netstat -utpln
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4220/php-fpm: maste
11、动态安装PHP模块
#进入安装包目录
cd /root/software/
#下载PHP模块安装包
wget http://pecl.php.net/get/imagick-3.4.3.tgz
#解压安装包
tar xf imagick-3.4.3.tgz
#进入安装包目录
cd imagick-3.4.3
#执行phpize命令
/usr/local/php7/bin/phpize
#编译安装
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make install