linux中安装php7

# 安装mcrypt

yum install -y php-mcrypt libmcrypt libmcrypt-devel

编译PHP7

# 下载源代码

wget  https://downloads.php.net/~ab/php-7.0.0RC5.tar.gz
tar zxvf php-7.0.0RC5.tar.gz

cd php-7.0.0RC5

# 配置参数

 

编译
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-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