安装 EPEL 源

  1. yum install epel-release
  2. yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

安装 Yum 源管理工具

  1. yum install yum-utils

安装 PHP7.3

  1. 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-xml
  1. yum install php73-php-zip

设置开机启动、运行服务

  1. systemctl enable php73-php-fpm
  2. systemctl start php73-php-fpm

查看 PHP

  1. php73 -v

查找php.ini位置

  1. find / -name php.ini

image.png

更多操作

  1. systemctl restart php73-php-fpm #重启
  2. systemctl start php73-php-fpm #启动
  3. systemctl stop php73-php-fpm #关闭
  4. systemctl status php73-php-fpm #检查状态

安装PHP7.4

  1. yum install -y php74-php-fpm php74-php-cli php74-php-bcmath php74-php-gd php74-php-json php74-php-mbstring php74-php-mcrypt php74-php-mysqlnd php74-php-opcache php74-php-pdo php74-php-pecl-crypto php74-php-pecl-mcrypt php74-php-pecl-geoip php74-php-recode php74-php-snmp php74-php-soap php74-php-xml
yum install php74-php-zip

设置开机启动、运行服务

systemctl enable php74-php-fpm
systemctl start php74-php-fpm

查看 PHP

php74 -v

查找php.ini位置

find / -name php.ini

image.png

更多操作

systemctl restart php74-php-fpm #重启
systemctl start php74-php-fpm #启动
systemctl stop php74-php-fpm #关闭
systemctl status php74-php-fpm #检查状态

linux php环境变量 软连接

  1. find / -name phpize 查看PHP 文件目录
  2. vim /etc/profile
  3. 添加 export PATH=$PATH:/www/server/php/73/bin (export PATH=$PATH:这里是你们的PHP 路径)

    #php
    export PATH=$PATH:/opt/remi/php74/root/usr/bin
    
  4. wq!保存退出 运行 source /etc/profile

  5. php -v
    image.png
  6. image.png