Centos7-1分钟快速yum安装php7.4或其他版本

以php7.4为例,其他版本自行替换"php74"。

#创建epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

#再创建两个repo

cat >/etc/yum.repos.d/remi-php74.repo<< EOF
[remi-php74]
name=php74 for Enterprise Linux 7 - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php74/x86_64/
failovermethod=priority
enabled=1
gpgcheck=0
EOF
cat >/etc/yum.repos.d/remi-safe.repo<< EOF
[remi-safe]
name=remi-safe for Enterprise Linux 7 - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/safe/x86_64/
failovermethod=priority
enabled=1
gpgcheck=0
EOF

#检查一下

[root@test11 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo       CentOS-Media.repo          epel.repo          remi-safe.repo
CentOS-CR.repo         CentOS-Sources.repo        epel.repo.rpmnew
CentOS-Debuginfo.repo  CentOS-Vault.repo          epel-testing.repo
CentOS-fasttrack.repo  CentOS-x86_64-kernel.repo  remi-php74.repo

[root@test11 ~]# cat /etc/yum.repos.d/remi-php74.repo 
[remi-php74]
name=php74 for Enterprise Linux 7 - 
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php74/x86_64/
failovermethod=priority
enabled=1
gpgcheck=0

[root@test11 ~]# cat /etc/yum.repos.d/remi-safe.repo 
[remi-safe]
name=remi-safe for Enterprise Linux 7 - 
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/safe/x86_64/
failovermethod=priority
enabled=1
gpgcheck=0

#yum makecache
#否则可能会从官方源安装php5.4

[root@test11 ~]# yum makecache 
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                               | 3.6 kB  00:00:00     
epel                                                                               | 4.7 kB  00:00:00     
extras                                                                             | 2.9 kB  00:00:00     
remi-php74                                                                         | 3.0 kB  00:00:00     
remi-safe                                                                          | 3.0 kB  00:00:00     
updates                                                                            | 2.9 kB  00:00:00     
(1/15): epel/x86_64/group_gz                                                       |  95 kB  00:00:00     
(2/15): epel/x86_64/updateinfo                                                     | 1.0 MB  00:00:00     
(3/15): epel/x86_64/prestodelta                                                    | 2.6 kB  00:00:00     
(4/15): epel/x86_64/filelists_db                                                   |  12 MB  00:00:07     
(5/15): remi-php74/primary_db                                                      | 228 kB  00:00:00     
(6/15): remi-php74/filelists_db                                                    | 134 kB  00:00:00     
(7/15): remi-php74/other_db                                                        |  45 kB  00:00:00     
(8/15): epel/x86_64/primary_db                                                     | 6.9 MB  00:00:07     
(9/15): epel/x86_64/other_db                                                       | 3.3 MB  00:00:01     
(10/15): remi-safe/filelists_db                                                    | 1.5 MB  00:00:00     
(11/15): remi-safe/other_db                                                        | 497 kB  00:00:00     
(12/15): remi-safe/primary_db                                                      | 1.9 MB  00:00:01     
(13/15): updates/7/x86_64/filelists_db                                             | 2.8 MB  00:00:00     
(14/15): updates/7/x86_64/other_db                                                 | 353 kB  00:00:00     
(15/15): updates/7/x86_64/primary_db                                               | 4.7 MB  00:00:01     
元数据缓存已建立

#yum安装php和其他组件,php后不需要再加数字,直接是7.4版本。

yum install php php-fpm php-mysqlnd php-devel php-gd php-mbstring php-pecl-mcrypt php-xml php-opcache php-pecl-memcached -y
总计                          4.4 MB/s |  71 MB  00:00:16 
[root@test11 ~]# php -v
PHP 7.4.14 (cli) (built: Jan  5 2021 10:45:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值