nginx环境准备
php环境准备:
##使用第三方扩展源安装php7.1* #不要安装如下rpm会导致失败 # rpm -Uvh https://d1.fedoraproject.org/pub/epe1/epe1-release-latest-7.noarch.rpm # rpm -Uvh https://mirror.webtatic.com/yum/e17/webtatic-release.rpm [root@nginx ~]# yum remove php-mysq1-5.4 php php-fpm php-common #配置php yum源 #安装完成后记得把这个php源注释掉 [root@nginx ~]# cat /etc/yum.repos.d/php.repo [webtatic-php] name = php Repository baseur1= http://us-east.repo.webtatic.com/yum/e17/x86_64/ gpgcheck =0 或者
yum 安装php源 yum install epel-release 安装REMI源 yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm 安装yum源管理工具 yum install yum-utils 安装php7.3 yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll systemctl enable php73-php-fpm systemctl start php73-php-fpm 查找php.ini位置 [root@xxx etc]# find /etc/opt/remi/php73 -name php.ini /etc/opt/remi/php73/php.ini
编辑/etc/opt/remi/php73/php.ini替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令:
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini
这里是将参数cgi.fix_pathinfo置为0,作用是:
php.ini中的配置参数cgi.fix_pathinfo,它是用来对设置cgi模式下为php是否提供绝对路径信息或PATH_INFO信息。没有这个参数之前PHP设置绝对路径PATH_TRANSLATED的值为SCRIPT_FILENAME,没有PATH_INFO值。设置cgi.fix_pathinfo=1后,cgi设置完整的路径信息PATH_TRANSLATED的值为SCRIPT_FILENAME,并且设置PATH_INFO信息;如果设为cgi.fix_pathinfo=0则只设置绝对路径PATH_TRANSLATED的值为SCRIPT_FILENAME。cgi.fix_pathinfo的默认值是1。
nginx默认是不会设置PATH_INFO环境变量的的值,需要通过正则匹配设置SCRIPT_FILENAME,但这样会带来安全隐患,需要把cgi.fix_pathinfo=0设置为0。但是一旦关闭这个这场,PHP就获取不到PATH_INFO信息,那些依赖PATH_INFO进行URL美化的程序就失效了。
重启php73-php-fpmsystemctl restart php73-php-fpm
更多操作:
查看PHP版本信息:
安装php7.1
##使用第三方扩展源安装php7.1* #不要安装如下rpm会导致失败 # rpm -Uvh https://d1.fedoraproject.org/pub/epe1/epe1-release-latest-7.noarch.rpm # rpm -Uvh https://mirror.webtatic.com/yum/e17/webtatic-release.rpm [root@nginx ~]# yum remove php-mysq1-5.4 php php-fpm php-common #配置php yum源 #安装完成后记得把这个php源注释掉 [root@nginx ~]# cat /etc/yum.repos.d/php.repo [webtatic-php] name = php Repository baseur1= http://us-east.repo.webtatic.com/yum/e17/x86_64/ gpgcheck =0 [root@nginx ~]# yum -y install php71w php71w-c1i php7lw-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb #配置php-fpm用户与Nginx的运行用户保持一致* #bash [root@nginx ~]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf [root@nginx ~]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf #启动php-fpm,并将其加入开机自启* [rootanginx~]# systemctl start php-fpm [rootanginx~]# systemctl enable php-fpm
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/p/18425306