快速编译安装PHP7步骤:
第一步: 安装必要一些依赖
# yum install php-mcrypt libmcrypt libmcrypt-devel libxml2-devel openssl-devel libcurl-devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 libjpeg-turbo-devel libmcrypt-devel mysql-devel -y
第二步: 下载php7源码包
# wget http://59.108.200.35/files/1164000003730786/cn2.php.net/distributions/php-7.0.0.tar.gz
# tar -xzvf php-7.0.0.tar.gz
# cd php-7.0.0
第三步: 编译安装
# './configure' '--prefix=/usr/local/php7' '--with-config-file-path=/usr/local/php7/etc' '--with-mcrypt=/usr/include' '--enable-mysqlnd' '--with-gd' '--with-iconv' '--with-zlib' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--enable-mbregex' '--enable-fpm' '--enable-mbstring' '--enable-ftp' '--enable-gd-native-ttf' '--with-openssl' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--with-curl' '--with-jpeg-dir' '--with-freetype-dir' '--with-mysqli' '--enable-embedded-mysqli' '--with-pdo-mysql'
# make
# make install
第四步: 配置php
cp php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /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.ini
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/opcache.so
extension=phalcon.so
extension=redis.so
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.profiler_enable = 0;
xdebug.show_mem_delta = 0;
error_log = /usr/local/php7/var/log/php-errors.log
display_errors = On
log_errors = On
#加入
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/opcache.so
#启动
/etc/init.d/php7-fpm start
#查看PHP版本
/usr/local/php7/bin/php -v
为了安全最好是去掉头信息 X-Powered-By: PHP/7.*.*
则修改 php.ini 文件 设置 expose_php = Off
vim /usr/local/php7/etc/php.ini
找到 expose_php = On
改为 expose_php = Off
make install的时候报错
make: *** [sapi/cli/php] Error 1
用的是第一种方法
手动打开MakeFile文件,找到EXTRA_LIBS那行,在最后加上 -liconv
用 make ZEND_EXTRA_LIBS='-liconv' 失败