1) 使用第三方扩展源安装php7.1
#1)配置PHP安装源
yum -y install epel-release
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm --no-check-certificate
rpm -Uvh webtatic-release.rpm
#2)安装PHP及相关插件
#2.1)卸载旧版本的php
rpm -e $(rpm -qa|grep php)
rpm -qa|grep php
#2.2)安装PHP及相关插件
yum install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd -y
yum install php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd -y
yum install php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb -y
#3)配置php-fpm用户与Nginx的运行用户保持一致
sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf
egrep "^user|^group" /etc/php-fpm.d/www.conf
#4)启动php-fpm,并将其加入开机自启
systemctl start php-fpm
systemctl enable php-fpm
lsof -i :9000
ps -ef|grep php-fpm
到此为止PHP就配好了。
2)配置nginx连接php
复制代码
cat >/etc/nginx/conf.d/01_pan.etiantian.org.conf<
server {
server_name pan.etiantian.org;
listen 80;
root /data/pan;
index index.php index.html;
location ~ \.php\$ {
#root /data/pan;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
cat /etc/nginx/conf.d/01_pan.etiantian.org.conf
nginx -t
systemctl restart nginx
复制代码
3)在/data目录下创建phpinfo.php文件
复制代码
mkdir /data/pan -p
cat> /data/pan/phpinfo.php<
phpinfo();
?>
EOF
复制代码
4)测试能否通过curl或浏览器访问
curl -H"host:pan.etiantian.org" 127.0.0.1/phpinfo.php
标签:php,fpm,环境,LNMP,php71w,conf,PHP,rpm,pan From: https://blog.51cto.com/u_15867943/5976257