事先准备
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel curl-devel libxslt-devel gcc-c++ zlib zlib-devel libtool openssl openssl-devel
1、下载源码
wget -O php-7.0.2.tar.gz http://php.net/get/php-7.0.2.tar.gz/from/a/mirror
解压
tar -zxvf php-7.0.2.tar.gz
cd php-7.0.2
2、安装配置
./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
这是开启php-fpm选项的。
3、编译安装
make
编译出现
make: *** [sapi/cli/php] Error 1的解决办法
make clean
之后再次
make
就可以了。
make install
4、检测
/usr/local/php/bin/php -v
看是否安装成功
成功之后会返回
PHP 7.0.2 (cli) (built: Mar 11 2018 14:03:28) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
5、配置文件
cp php.ini-development /usr/local/php/lib/php.ini
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 -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
6、启动php-fpm
/etc/init.d/php-fpm
7、停止php-fpm
killall php-fpm
网友评论