How to install php on CentOS?

青灯夜游
Release: 2023-02-26 19:00:01
Original
6725 people have browsed it

How to install php on CentOS?

Steps to install php on CentOS:

1. Configure yum library

First, Remi and EPEL yum repositories need to be enabled on the system. Use the following command to install the EPEL repository on CentOS system

Use this command to install the epel-release yum repository

# yum install epel-release
Copy after login

Now execute one of the following commands according to your operating system version to install the Remi storage library.

$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Copy after login

2. Install PHP 7 on CentOS 6

Your system is ready to install PHP from the yum repository. Use one of the following commands to install PHP 7.3 or PHP 7.2 or PHP 7.1 on your system as required.

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

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

## 安装PHP 7.1 
$ yum --enablerepo=remi-php71 install php
Copy after login

I have installed the latest version of PHP 7.3 on my system. Now run the following command to check the currently used PHP version of your system.

$ 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
Copy after login

Installing PHP Modules

You may also need to install additional PHP modules based on your application needs.

The following commands will install some useful PHP modules.

### 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
Copy after login

You can run the following command to search for other available PHP modules under the configured yum repository.

The following example command searches all modules for 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
...
...
Copy after login

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to install php on CentOS?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!