如何在CentOS和RHEL上安裝PHP7

不言
發布: 2023-04-05 19:02:01
原創
3078 人瀏覽過

php7.3是php最新的穩定版本,yum儲存庫正在為php7提供RPM套件。這篇文章將使用remi和epel-yum儲存庫在你的系統上安裝所需的軟體包,將介紹在CentOS和Redhat7伺服器上安裝php 7.3、php 7.2、php 7.1。

如何在CentOS和RHEL上安裝PHP7

設定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.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!