登录  /  注册
如何在CentOS和RHEL上安装PHP7
不言
发布: 2023-04-05 19:02:01
原创
2602人浏览过

php7.3是php的最新稳定版本,yum存储库正在为php7提供RPM包。本篇文章将使用remi和epel-yum存储库在你的系统上安装所需的软件包,将介绍在CentOS和Redhat7服务器上安装php 7.3、php 7.2、php 7.1。

微信截图_20190404132444.png

设置yum存储库

首先,需要在系统上启用Remi和EPEL yum存储库。使用以下命令在CentOS和Red Hat 7/6系统上安装EPEL存储库

使用此命令在系统上安装EPEL yum存储库

$ sudo yum install epel-release
登录后复制

现在根据你的操作系统版本执行以下命令之一以安装REMI存储库。

$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
登录后复制

在CentOS上安装php 7

你的系统已准备好从yum存储库安装PHP。根据你的需求,使用以下命令之一在系统上安装php 7.3、php 7.2或php 7.1。

## Install PHP 7.3 
$ yum --enablerepo=remi-php73 install php

## Install PHP 7.2 
$ yum --enablerepo=remi-php72 install php

## Install PHP 7.1 
$ yum --enablerepo=remi-php71 install php
登录后复制

假设已经在系统上安装了最新版本的php 7.3。现在运行下面的命令来检查系统上当前运行的PHP版本。

$ php -v

PHP 7.3.0 (cli) (built: Dec  4 2018 16:12:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
登录后复制

安装PHP模块

可能还需要根据应用程序需求安装其他PHP模块。下面的命令将安装一些更有用的PHP模块。

### For PHP 7.3
$ yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

### For PHP 7.2
$ yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

### For PHP 7.1
$ yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
登录后复制

可以运行以下命令来搜索配置yum存储库下的其他可用PHP模块。下面的示例命令将搜索PHP 7.3的所有模块。

$ yum --enablerepo=remi-php73 search php | grep php73

php73.x86_64 : Package that installs PHP 7.3
php73-php.x86_64 : PHP scripting language for creating dynamic web sites
php73-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
php73-php-brotli.x86_64 : Brotli Extension for PHP
php73-php-cli.x86_64 : Command-line interface for PHP
php73-php-common.x86_64 : Common files for PHP
php73-php-componere.x86_64 : Composing PHP classes at runtime
php73-php-dba.x86_64 : A database abstraction layer module for PHP applications
php73-php-dbg.x86_64 : The interactive PHP debugger
php73-php-devel.x86_64 : Files needed for building PHP extensions
php73-php-embedded.x86_64 : PHP library for embedding in applications
php73-php-enchant.x86_64 : Enchant spelling extension for PHP applications
php73-php-fpm.x86_64 : PHP FastCGI Process Manager
php73-php-gd.x86_64 : A module for PHP applications for using the gd graphics
...
...
登录后复制

本篇文章到这里就已经全部结束了,更多其他精彩内容大家可以关注PHP中文网的php视频教程栏目!!!

以上就是如何在CentOS和RHEL上安装PHP7的详细内容,更多请关注php中文网其它相关文章!

相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学