CentOS7下yum安装php7
后台-插件-广告管理-内容页头部广告(手机) |
1.安装epel-release
EPEL(Extra Packages for Enterprise Linux)存储库提供了标准 Red Hat 和 CentOS 存储库中未包含的其他软件包。EPEL 存储库的创建是因为 Fedora 贡献者希望使用他们在 Red Hat Enterprise Linux(RHEL)及其衍生产品(如CentOS,Oracle Linux和Scientific Linux)上维护的软件包。
启用此存储库后,您可以访问流行的软件包,包括 Nginx等。
命令:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
- [root@centos79-3 ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- --2023-08-31 15:37:33-- https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 38.145.60.22, 38.145.60.24, 38.145.60.23
- Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|38.145.60.22|:443... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 15608 (15K) [application/x-rpm]
- Saving to: ‘epel-release-latest-7.noarch.rpm’
- 100%[================================================================>] 15,608 48.1KB/s in 0.3s
- 2023-08-31 15:37:35 (48.1 KB/s) - ‘epel-release-latest-7.noarch.rpm’ saved [15608/15608]
- [root@centos79-3 ~]# ls
- anaconda-ks.cfg basic_init.sh epel-release-latest-7.noarch.rpm
- [root@centos79-3 ~]# rpm -ivh epel-release-latest-7.noarch.rpm
- Preparing... ################################# [100%]
- package epel-release-7-14.noarch is already installed
- [root@centos79-3 ~]# cd /etc/yum.repos.d/
- [root@centos79-3 yum.repos.d]# ls
- bak epel.repo nginx.repo webtatic.repo
- CentOS7.repo epel-testing.repo webtatic-archive.repo webtatic-testing.repo
- [root@centos79-3 yum.repos.d]#
通过yum repolist验证epel存储库是否启用,该命令将显示已启用的存储库的 repo ID,名称和程序包数量。输出的信息中如包含 EPEL存储库这一行,说明EPEL库已启用。
命令:
yum repolist
- [root@centos79-3 yum.repos.d]# yum repolist
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * epel: mirrors.bfsu.edu.cn
- repo id repo name status
- CentOS7 "localserver" 4,070
- *epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,770
- nginx-stable/7/x86_64 nginx stable repo 318
- webtatic/x86_64 Webtatic Repository EL7 - x86_64 789
- repolist: 18,947
- [root@centos79-3 yum.repos.d]#
2.安装php7的rpm源
对于服务器而言,php7的rpm源最为常见的即是提供 web 服务,而对于 web 服务中常用的一些软件,在系统默认的源下,一般版本较低,如若需要使用相对较新的版本(如 PHP),webtatic 源是一个很好的选择。
命令:
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm --no-check-certificate
rpm -ivh webtatic-release.rpm
yum list |grep php7
- [root@centos79-3 ~]# wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm --no-check-certificate
- --2023-08-31 15:50:44-- https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- Resolving mirror.webtatic.com (mirror.webtatic.com)... 104.21.71.8, 172.67.141.68, 2606:4700:3037::6815:4708, ...
- Connecting to mirror.webtatic.com (mirror.webtatic.com)|104.21.71.8|:443... connected.
- WARNING: cannot verify mirror.webtatic.com's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=E1’:
- Issued certificate has expired.
- HTTP request sent, awaiting response... 200 OK
- Length: 13152 (13K) [application/x-rpm]
- Saving to: ‘webtatic-release.rpm’
- 100%[================================================================>] 13,152 40.2KB/s in 0.3s
- 2023-08-31 15:50:48 (40.2 KB/s) - ‘webtatic-release.rpm’ saved [13152/13152]
- [root@centos79-3 ~]# ls
- anaconda-ks.cfg basic_init.sh epel-release-latest-7.noarch.rpm webtatic-release.rpm
- [root@centos79-3 ~]# rpm -ivh webtatic-release.rpm
- Preparing... ################################# [100%]
- package webtatic-release-7-3.noarch is already installed
- [root@centos79-3 yum.repos.d]# yum list |grep php7
- mod_php71w.x86_64 7.1.33-1.w7 webtatic
- mod_php72w.x86_64 7.2.34-1.w7 webtatic
- php70w.x86_64 7.0.33-1.w7 webtatic
- php70w-bcmath.x86_64 7.0.33-1.w7 webtatic
- php70w-cli.x86_64 7.0.33-1.w7 webtatic
- php70w-common.x86_64 7.0.33-1.w7 webtatic
- php70w-dba.x86_64 7.0.33-1.w7 webtatic
- php70w-devel.x86_64 7.0.33-1.w7 webtatic
- php70w-embedded.x86_64 7.0.33-1.w7 webtatic
- php70w-enchant.x86_64 7.0.33-1.w7 webtatic
- php70w-fpm.x86_64 7.0.33-1.w7 webtatic
- php70w-gd.x86_64 7.0.33-1.w7 webtatic
- php70w-imap.x86_64 7.0.33-1.w7 webtatic
- php70w-interbase.x86_64 7.0.33-1.w7 webtatic
- php70w-intl.x86_64 7.0.33-1.w7 webtatic
- php70w-ldap.x86_64 7.0.33-1.w7 webtatic
- php70w-mbstring.x86_64 7.0.33-1.w7 webtatic
- php70w-mcrypt.x86_64 7.0.33-1.w7 webtatic
- php70w-mysql.x86_64 7.0.33-1.w7 webtatic
- php70w-mysqlnd.x86_64 7.0.33-1.w7 webtatic
- php70w-odbc.x86_64 7.0.33-1.w7 webtatic
- php70w-opcache.x86_64 7.0.33-1.w7 webtatic
- php70w-pdo.x86_64 7.0.33-1.w7 webtatic
- php70w-pdo_dblib.x86_64 7.0.33-1.w7 webtatic
- php70w-pear.noarch 1:1.10.4-1.w7 webtatic
- php70w-pecl-apcu.x86_64 5.1.9-1.w7 webtatic
- php70w-pecl-apcu-devel.x86_64 5.1.9-1.w7 webtatic
- php70w-pecl-geoip.x86_64 1.1.1-1.w7 webtatic
- php70w-pecl-igbinary.x86_64 2.0.5-1.w7 webtatic
- php70w-pecl-igbinary-devel.x86_64 2.0.5-1.w7 webtatic
- php70w-pecl-imagick.x86_64 3.4.3-1.w7 webtatic
- php70w-pecl-imagick-devel.x86_64 3.4.3-1.w7 webtatic
- php70w-pecl-memcached.x86_64 3.0.4-1.w7 webtatic
- php70w-pecl-mongodb.x86_64 1.5.3-1.w7 webtatic
- php70w-pecl-redis.x86_64 3.1.6-1.w7 webtatic
- php70w-pecl-xdebug.x86_64 2.6.1-1.w7 webtatic
- php70w-pgsql.x86_64 7.0.33-1.w7 webtatic
- php70w-phpdbg.x86_64 7.0.33-1.w7 webtatic
- php70w-process.x86_64 7.0.33-1.w7 webtatic
- php70w-pspell.x86_64 7.0.33-1.w7 webtatic
- php70w-recode.x86_64 7.0.33-1.w7 webtatic
- php70w-snmp.x86_64 7.0.33-1.w7 webtatic
- php70w-soap.x86_64 7.0.33-1.w7 webtatic
- php70w-tidy.x86_64 7.0.33-1.w7 webtatic
- php70w-xml.x86_64 7.0.33-1.w7 webtatic
- php70w-xmlrpc.x86_64 7.0.33-1.w7 webtatic
- php71w-bcmath.x86_64 7.1.33-1.w7 webtatic
- php71w-cli.x86_64 7.1.33-1.w7 webtatic
- php71w-common.x86_64 7.1.33-1.w7 webtatic
- php71w-dba.x86_64 7.1.33-1.w7 webtatic
- php71w-devel.x86_64 7.1.33-1.w7 webtatic
- php71w-embedded.x86_64 7.1.33-1.w7 webtatic
- php71w-enchant.x86_64 7.1.33-1.w7 webtatic
- php71w-fpm.x86_64 7.1.33-1.w7 webtatic
- php71w-gd.x86_64 7.1.33-1.w7 webtatic
- php71w-imap.x86_64 7.1.33-1.w7 webtatic
- php71w-interbase.x86_64 7.1.33-1.w7 webtatic
- php71w-intl.x86_64 7.1.33-1.w7 webtatic
- php71w-ldap.x86_64 7.1.33-1.w7 webtatic
- php71w-mbstring.x86_64 7.1.33-1.w7 webtatic
- php71w-mcrypt.x86_64 7.1.33-1.w7 webtatic
- php71w-mysql.x86_64 7.1.33-1.w7 webtatic
- php71w-mysqlnd.x86_64 7.1.33-1.w7 webtatic
- php71w-odbc.x86_64 7.1.33-1.w7 webtatic
- php71w-opcache.x86_64 7.1.33-1.w7 webtatic
- php71w-pdo.x86_64 7.1.33-1.w7 webtatic
- php71w-pdo_dblib.x86_64 7.1.33-1.w7 webtatic
- php71w-pear.noarch 1:1.10.4-1.w7 webtatic
- php71w-pecl-apcu.x86_64 5.1.9-1.w7 webtatic
- php71w-pecl-apcu-devel.x86_64 5.1.9-1.w7 webtatic
- php71w-pecl-geoip.x86_64 1.1.1-1.w7 webtatic
- php71w-pecl-igbinary.x86_64 2.0.5-1.w7 webtatic
- php71w-pecl-igbinary-devel.x86_64 2.0.5-1.w7 webtatic
- php71w-pecl-imagick.x86_64 3.4.3-1.w7 webtatic
- php71w-pecl-imagick-devel.x86_64 3.4.3-1.w7 webtatic
- php71w-pecl-memcached.x86_64 3.0.4-1.w7 webtatic
- php71w-pecl-mongodb.x86_64 1.5.3-1.w7 webtatic
- php71w-pecl-redis.x86_64 3.1.6-1.w7 webtatic
- php71w-pecl-xdebug.x86_64 2.6.1-1.w7 webtatic
- php71w-pgsql.x86_64 7.1.33-1.w7 webtatic
- php71w-phpdbg.x86_64 7.1.33-1.w7 webtatic
- php71w-process.x86_64 7.1.33-1.w7 webtatic
- php71w-pspell.x86_64 7.1.33-1.w7 webtatic
- php71w-recode.x86_64 7.1.33-1.w7 webtatic
- php71w-snmp.x86_64 7.1.33-1.w7 webtatic
- php71w-soap.x86_64 7.1.33-1.w7 webtatic
- php71w-tidy.x86_64 7.1.33-1.w7 webtatic
- php71w-xml.x86_64 7.1.33-1.w7 webtatic
- php71w-xmlrpc.x86_64 7.1.33-1.w7 webtatic
- php72w-bcmath.x86_64 7.2.34-1.w7 webtatic
- php72w-cli.x86_64 7.2.34-1.w7 webtatic
- php72w-common.x86_64 7.2.34-1.w7 webtatic
- php72w-dba.x86_64 7.2.34-1.w7 webtatic
- php72w-devel.x86_64 7.2.34-1.w7 webtatic
- php72w-embedded.x86_64 7.2.34-1.w7 webtatic
- php72w-enchant.x86_64 7.2.34-1.w7 webtatic
- php72w-fpm.x86_64 7.2.34-1.w7 webtatic
- php72w-gd.x86_64 7.2.34-1.w7 webtatic
- php72w-imap.x86_64 7.2.34-1.w7 webtatic
- php72w-interbase.x86_64 7.2.34-1.w7 webtatic
- php72w-intl.x86_64 7.2.34-1.w7 webtatic
- php72w-ldap.x86_64 7.2.34-1.w7 webtatic
- php72w-mbstring.x86_64 7.2.34-1.w7 webtatic
- php72w-mysql.x86_64 7.2.34-1.w7 webtatic
- php72w-mysqlnd.x86_64 7.2.34-1.w7 webtatic
- php72w-odbc.x86_64 7.2.34-1.w7 webtatic
- php72w-opcache.x86_64 7.2.34-1.w7 webtatic
- php72w-pdo.x86_64 7.2.34-1.w7 webtatic
- php72w-pdo_dblib.x86_64 7.2.34-1.w7 webtatic
- php72w-pear.noarch 1:1.10.12-1.w7 webtatic
- php72w-pecl-apcu.x86_64 5.1.18-1.w7 webtatic
- php72w-pecl-apcu-devel.x86_64 5.1.18-1.w7 webtatic
- php72w-pecl-geoip.x86_64 1.1.1-1.2.w7 webtatic
- php72w-pecl-igbinary.x86_64 3.1.2-1.w7 webtatic
- php72w-pecl-igbinary-devel.x86_64 3.1.2-1.w7 webtatic
- php72w-pecl-imagick.x86_64 3.4.4-1.2.w7 webtatic
- php72w-pecl-imagick-devel.x86_64 3.4.4-1.2.w7 webtatic
- php72w-pecl-libsodium.x86_64 1.0.6-1.2.w7 webtatic
- php72w-pecl-memcached.x86_64 3.1.5-1.w7 webtatic
- php72w-pecl-mongodb.x86_64 1.7.4-1.w7 webtatic
- php72w-pecl-redis.x86_64 3.1.6-1.w7 webtatic
- php72w-pecl-xdebug.x86_64 2.9.6-1.w7 webtatic
- php72w-pgsql.x86_64 7.2.34-1.w7 webtatic
- php72w-phpdbg.x86_64 7.2.34-1.w7 webtatic
- php72w-process.x86_64 7.2.34-1.w7 webtatic
- php72w-pspell.x86_64 7.2.34-1.w7 webtatic
- php72w-recode.x86_64 7.2.34-1.w7 webtatic
- php72w-snmp.x86_64 7.2.34-1.w7 webtatic
- php72w-soap.x86_64 7.2.34-1.w7 webtatic
- php72w-sodium.x86_64 7.2.34-1.w7 webtatic
- php72w-tidy.x86_64 7.2.34-1.w7 webtatic
- php72w-xml.x86_64 7.2.34-1.w7 webtatic
- php72w-xmlrpc.x86_64 7.2.34-1.w7 webtatic
- [root@centos79-3 yum.repos.d]#
3.安装php7
命令:
yum install -y php72w php72w-cli php72w-common php72w-devel php72w-mysql php72w-fpm
rpm -qa | grep php72
- [root@centos79-3 yum.repos.d]# yum install -y php72w php72w-cli php72w-common php72w-devel php72w-mysql php72w-fpm php72w-devel
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * epel: mirrors.bfsu.edu.cn
- Resolving Dependencies
- --> Running transaction check
- ---> Package php72w-fpm.x86_64 0:7.2.34-1.w7 will be installed
- --> Processing Dependency: php72w-common(x86-64) = 7.2.34-1.w7 for package: php72w-fpm-7.2.34-1.w7.x86_64
- ---> Package php72w-mysql.x86_64 0:7.2.34-1.w7 will be installed
- --> Processing Dependency: php72w-pdo(x86-64) for package: php72w-mysql-7.2.34-1.w7.x86_64
- --> Running transaction check
- ---> Package php72w-common.x86_64 0:7.2.34-1.w7 will be installed
- ---> Package php72w-pdo.x86_64 0:7.2.34-1.w7 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- =============================================================================================================================================================
- Package Arch Version Repository Size
- =============================================================================================================================================================
- Installing:
- php72w-fpm x86_64 7.2.34-1.w7 webtatic 1.6 M
- php72w-mysql x86_64 7.2.34-1.w7 webtatic 83 k
- Installing for dependencies:
- php72w-common x86_64 7.2.34-1.w7 webtatic 1.3 M
- php72w-pdo x86_64 7.2.34-1.w7 webtatic 90 k
- Transaction Summary
- =============================================================================================================================================================
- Install 2 Packages (+2 Dependent packages)
- Total download size: 3.0 M
- Installed size: 18 M
- Downloading packages:
- (1/4): php72w-common-7.2.34-1.w7.x86_64.rpm | 1.3 MB 00:00:04
- (2/4): php72w-mysql-7.2.34-1.w7.x86_64.rpm | 83 kB 00:00:00
- (3/4): php72w-pdo-7.2.34-1.w7.x86_64.rpm | 90 kB 00:00:00
- (4/4): php72w-fpm-7.2.34-1.w7.x86_64.rpm | 1.6 MB 00:00:04
- -------------------------------------------------------------------------------------------------------------------------------------------------------------
- Total 624 kB/s | 3.0 MB 00:00:04
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Installing : php72w-common-7.2.34-1.w7.x86_64 1/4
- Installing : php72w-pdo-7.2.34-1.w7.x86_64 2/4
- Installing : php72w-mysql-7.2.34-1.w7.x86_64 3/4
- Installing : php72w-fpm-7.2.34-1.w7.x86_64 4/4
- Verifying : php72w-mysql-7.2.34-1.w7.x86_64 1/4
- Verifying : php72w-fpm-7.2.34-1.w7.x86_64 2/4
- Verifying : php72w-pdo-7.2.34-1.w7.x86_64 3/4
- Verifying : php72w-common-7.2.34-1.w7.x86_64 4/4
- Installed:
- php72w-fpm.x86_64 0:7.2.34-1.w7 php72w-mysql.x86_64 0:7.2.34-1.w7
- Dependency Installed:
- php72w-common.x86_64 0:7.2.34-1.w7 php72w-pdo.x86_64 0:7.2.34-1.w7
- Complete!
- [root@centos79-3 yum.repos.d]# rpm -qa | grep php72w
- php72w-fpm-7.2.34-1.w7.x86_64
- php72w-common-7.2.34-1.w7.x86_64
- php72w-mysql-7.2.34-1.w7.x86_64
- php72w-cli-7.2.34-1.w7.x86_64
- php72w-pdo-7.2.34-1.w7.x86_64
- php72w-devel-7.2.34-1.w7.x86_64
- [root@centos79-3 yum.repos.d]#
4.查看php版本
命令:
php -v
- [root@centos79-3 yum.repos.d]# php -v
- PHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )
- Copyright (c) 1997-2018 The PHP Group
- Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
- [root@centos79-3 yum.repos.d]#
另外:
php-fpm启动
命令:
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
- [root@centos79-3 yum.repos.d]# systemctl enable php-fpm
- Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
- [root@centos79-3 yum.repos.d]#
- [root@centos79-3 yum.repos.d]# systemctl start php-fpm
- [root@centos79-3 yum.repos.d]#
- [root@centos79-3 yum.repos.d]# systemctl status php-fpm
- ● php-fpm.service - The PHP FastCGI Process Manager
- Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
- Active: active (running) since Thu 2023-08-31 16:02:13 CST; 1s ago
- Main PID: 20949 (php-fpm)
- Status: "Ready to handle connections"
- CGroup: /system.slice/php-fpm.service
- ├─20949 php-fpm: master process (/etc/php-fpm.conf)
- ├─20951 php-fpm: pool www
- ├─20952 php-fpm: pool www
- ├─20953 php-fpm: pool www
- ├─20954 php-fpm: pool www
- └─20955 php-fpm: pool www
- Aug 31 16:02:13 centos79-3 systemd[1]: Starting The PHP FastCGI Process Manager...
- Aug 31 16:02:13 centos79-3 systemd[1]: Started The PHP FastCGI Process Manager.
- [root@centos79-3 yum.repos.d]#
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。
在线投稿:投稿 站长QQ:1888636
后台-插件-广告管理-内容页尾部广告(手机) |