• 安装EPEL源
yum install epel-release -y
  • 安装 REMI 源
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
  • 安装 Yum 源管理工具
yum install -y 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
  • 查看php版本
[root@xgblog ~]# php73 -v
PHP 7.3.20 (cli) (built: Jul  7 2020 07:53:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies
  • 加个软链, 方便自己
[root@xgblog bin]# which php73
/usr/bin/php73
打开到 /usr/bin/ 目录, ls -la 可以判断实际指向到/opt/remi/php73/root/usr/bin/php
# 创建软链
ln -s /opt/remi/php73/root/usr/bin/php /usr/bin/php
[root@xgblog bin]# php -v
PHP 7.3.20 (cli) (built: Jul  7 2020 07:53:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies
  • 重启php服务
systemctl restart php73-php-fpm
  • 确定9000端口被打开
[root@localhost ~]# netstat -nl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN 
  • 编辑nginx配置文件, 参考下面的编辑方式
vim /etc/nginx/nginx.conf
>
server {
    listen       80;
    server_name  abc.de.com;
    root   /var/www/html;
    index  index.php index.html index.htm;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    access_log /dev/null;
    error_log  /dev/null;
    

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

# 下面的内容拷贝到对应的位置
    location ~ \.php {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;

        fastcgi_split_path_info  ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        include        fastcgi.conf;
    }
}
  • 设置php服务开机自启动
systemctl enable php73-php-fpm

# 更多php相关操作
systemctl restart php73-php-fpm #重启
systemctl start php73-php-fpm #启动
systemctl stop php73-php-fpm #关闭
systemctl status php73-php-fpm #检查状态

标签: none

添加新评论