centos Tutorial for Installing php through yum

  • 2021-07-18 09:39:39
  • OfStack

First, let's introduce centos to install php through yum

1. Add yum software repository with php

sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

2. Install php related software, and select yes during execution


sudo yum install php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-gd.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysql.x86_64 php71w-pdo.x86_64

3. Install php71-fpm

sudo yum install php71w-fpm.x86_64

Wait for installation to complete enter php-version to view php version

ps: Let's look at the steps of installing PHP 7.2 under CentOS 7

1. Install the source

To install php72w, you need to configure an additional yum source address, otherwise you will report an error and cannot find the relevant software package.

The php high version of the yum source address has two parts, one of which is epel-release, and the other one is from webtatic. If you skip epel-release, an error will pop up when installing webtatic.

So, the command you need here is:

rpm -Uvh https://dl.Fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Of course, you can also choose the following command, which is also the same effect.

yum install epel-release -y

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2. Clear version history

To prevent php collisions on CentOS, it is better to execute this command 1 times first.

yum -y remove php*

3. Install the expansion pack

In fact, there are many corresponding extension libraries. Here, everyone should pay attention to cli and fpm, while other related packages depend on your needs.


yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel

There are also more luxurious versions:


yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

4. After installation, start the service


systemctl enable php-fpm.service

systemctl start php-fpm.service

5. Successful installation

Summarize

Above is this site to introduce centos through yum installation php tutorial, I hope to help you!


Related articles: