php7编译
安装源配置
1.下载 epel 安装源
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- 安装 epel 安装源
rpm -Uvh epel-release-latest-7.noarch.rpm
2.安装 webtatic 安装源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3.更新yum缓存
yum makecache fast



安装PHP7及相关插件
1.查看yum源是否能搜索到PHP7
yum list | php7
2.安装php7及相关插件
yum install --enablerepo=webtatic-testing php71w-fpm php71w-opcache php71w-cli php71w-gd php71w-imap php71w-mysqlnd php71w-mbstring php71w-mcrypt php71w-pdo php71w-pecl-apcu php71w-pecl-mongodb php71w-pecl-redis php71w-pgsql php71w-xml php71w-xmlrpc php71w-devel mod_php71w

验证是否安装成功
1.查看PHP版本
php -v
2.查看PHP安装的插件
php -m


配置PHP-FPM(以socket方式)
- vi /etc/php-fpm.d/www.conf
将listen = 127.0.0.1:9000改为:
listen = /var/run/php-fpm/php-fpm.sock
3.启动php-fpm
systemctl start php-fpm
4.查看启动是否成功
ps -ef | grep php-fpm


安装以及配置nginx
1.安装nginx
yum install -y nginx
2.验证nginx是否安装成功
nginx -v
3.整合nginx和php-fpm
vi /etc/nginx/nginx.conf
添加以下内容
location ~ .php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
4.重启nginx
systemctl restart nginx


6
以PHP-FPM方式运行PHP7
1.新建个php文件
touch /usr/share/nginx/html/info.php
2.添加以下内容:
<?php
phpinfo();
3.浏览器输入地址 http://127.0.0.1/info.php
看到输出内容表示运行成功。