linux centos7 yum php7.2 php扩展 配置nginx支持php-fpm

  • Post author:
  • Post category:php


转载:

https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/


【原地址配了图 很详细】

(如果不是root用户要是用root权限 所有的命令前加上 sudo)

centos7安装php7.2

1、yum install epel-release [安装所需的依赖]
2、yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm [安装php72的源]
3、yum install yum-utils
4、yum-config-manager --enable remi-php72 [查看php72的扩展]
5、yum update  [更新yum源]
6、sudo yum search php72 | more [查看当前的yum中有哪些php扩展]
   sudo yum search php72 | egrep 'fpm|gd|mysql|memcache' [匹配查看某种源的包名]
7、sudo yum install php72 [安装php72]
8、yum install php72-php-fpm php72-php-gd php72-php-json php72-php-mbstring php72-php-mysqlnd php72-php-xml php72-php-xmlrpc php72-php-opcache  [安装php的扩展]
9、php72  --version [查看php的版本]
10、php72  -m [查看php的扩展]
11、ps aux | grep php-fpm  [查看php-fpm的启动情况]
12、systemctl start php72-php-fpm.service [启动php-fpm的服务  重启:restart  停止:stop]
13、systemctl enable php72-php-fpm.service  [添加php为开启启动项]
14、systemctl status php72-php-fpm.service [查看php-fpm的状态]

配置nginx支持php-fpm

[yum 安装nginx yum install -y nginx]

vi /etc/nginx/conf.d/default.conf
server {
        listen 80;
        server_name 服务器的ip地址 localhost;

        location / {
                root /usr/share/nginx/html/;
                index index.php  index.html  index.htm;
        }

        location ~ \.php$ {
                root /usr/share/nginx/html/;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME           $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

systemctl restart nginx
vi /usr/share/nginx/html/index.php

<?php
echo phpinfo();

:wq

访问ip地址  出现phpinfo()的内容