Maison  >  Article  >  Opération et maintenance  >  Comment installer PHP7 sur Linux Centos

Comment installer PHP7 sur Linux Centos

WBOY
WBOYavant
2023-05-15 20:16:041925parcourir

Comment installer PHP7 sur Linux Centos : 1. Installez la source EPEL, la source REMI et l'outil de gestion des sources Yum via la commande "yum -y install" ; Utilisez la commande "yum -y" pour installer PHP ; 3. Vérifiez le package d'installation de PHP ; 4. Modifiez la configuration php.ini ; 5. Redémarrez "php74-php-fpm" via "systemctl restart php74-php-fpm".

1. Préparation des fichiers et des outils de la bibliothèque avant l'installation

1. Installez d'abord la source EPEL

yum -y install epel-release

2. Source REMI# 🎜🎜#

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

3. Installez l'outil de gestion des sources Yum

yum -y install yum-utils

2. Installez PHP

1. Installez PHP

yum -y --enablerepo=remi install php74-php php74-php-fpm php74-php-bcmath php74-php-ctype php74-php-curl php74-php-dom php74-php-gd php74-php-hash php74-php-iconv php74-php-intl php74-php-mbstring php74-php-pdo_mysql php74-php-simplexml php74-php-soap php74-php-xsl php74-php-zip php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql php74-php-cli php74-php-json php74-php-mcrypt php74-php-mysqlnd php74-php-pecl-crypto php74-php-pecl-mcrypt php74-php-pecl-geoip php74-php-recode  php74-php-xmll
#🎜. 🎜#2 .Redémarrez l'ordinateur, sinon vous ne pourrez peut-être pas démarrer php

reboot

3. Configurez le démarrage et exécutez les services

systemctl start php74-php-fpm
systemctl enable php74-php-fpm

3. Configurez PHP#🎜. 🎜#

1 .Affichez le package d'installation PHP

[root@VM-0-5-centos ~]# rpm -qa | grep php
oniguruma5php-6.9.7.1-1.el7.remi.x86_64
php74-php-common-7.4.24-1.el7.remi.x86_64
php74-php-7.4.24-1.el7.remi.x86_64
php74-php-xml-7.4.24-1.el7.remi.x86_64
php74-php-pdo-7.4.24-1.el7.remi.x86_64
php74-php-pecl-mysql-1.0.0-0.23.20190415.d7643af.el7.remi.x86_64
php74-php-fpm-7.4.24-1.el7.remi.x86_64
php74-php-bcmath-7.4.24-1.el7.remi.x86_64
php74-php-pecl-recode-1.0.0~DEV.20190723-4.el7.remi.x86_64
php74-runtime-1.0-3.el7.remi.x86_64
php74-php-mysqlnd-7.4.24-1.el7.remi.x86_64
php74-php-pecl-crypto-0.3.2-1.el7.remi.x86_64
php74-php-soap-7.4.24-1.el7.remi.x86_64
php74-php-intl-7.4.24-1.el7.remi.x86_64
php74-php-pecl-zip-1.19.5-1.el7.remi.x86_64
php74-php-json-7.4.24-1.el7.remi.x86_64
php74-php-cli-7.4.24-1.el7.remi.x86_64
php74-php-sodium-7.4.24-1.el7.remi.x86_64
php74-php-pecl-geoip-1.1.1-11.el7.remi.x86_64
php74-php-snmp-7.4.24-1.el7.remi.x86_64
php74-php-pecl-mcrypt-1.0.4-1.el7.remi.x86_64
php74-php-gd-7.4.24-1.el7.remi.x86_64
php74-php-mbstring-7.4.24-1.el7.remi.x86_64

2 Recherchez : php74-php-fpm-7.4.24-1.el7.remi.x86_64 emplacement d'installation

[root@VM-0-5-centos ~]# rpm -ql php74-php-fpm-7.4.24-1.el7.remi.x86_64/etc/logrotate.d/php74-php-fpm/etc/opt/remi/php74/php-fpm.conf/etc/opt/remi/php74/php-fpm.d/etc/opt/remi/php74/php-fpm.d/www.conf/etc/opt/remi/php74/sysconfig/php-fpm/etc/systemd/system/php74-php-fpm.service.d/opt/remi/php74/root/usr/sbin/php-fpm/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/php-fpm.conf.default/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/www.conf.default/opt/remi/php74/root/usr/share/fpm/opt/remi/php74/root/usr/share/fpm/status.html/opt/remi/php74/root/usr/share/licenses/php74-php-fpm-7.4.24/opt/remi/php74/root/usr/share/licenses/php74-php-fpm-7.4.24/fpm_LICENSE/opt/remi/php74/root/usr/share/man/man8/php-fpm.8.gz/usr/lib/systemd/system/php74-php-fpm.service/var/opt/remi/php74/lib/php/opcache/var/opt/remi/php74/lib/php/session/var/opt/remi/php74/lib/php/wsdlcache/var/opt/remi/php74/log/php-fpm/var/opt/remi/php74/run/php-fpm
.

3. Recherchez l'emplacement du php .ini :

[root@localhost src]# find /etc/opt/remi/php74 -name php.ini/etc/opt/remi/php74/php.ini

4 Modifiez /etc/opt/remi/php74/php.ini et remplacez ;cgi.fix_pathinfo=1 par cgi.fix_pathinfo=0. ;

[root@localhost src]# vim /etc/opt/remi/php74/php.ini
cgi.fix_pathinfo=0
#🎜 🎜#5. Redémarrez php74-php-fpm

systemctl restart php74-php-fpm

6. Plus d'opérations

systemctl restart php74-php-fpm #重启
systemctl start php74-php-fpm #启动
systemctl stop php74-php-fpm #关闭
systemctl status php74-php-fpm #检查状态

4. Définissez les connexions logicielles PHP et les variables d'environnement# 🎜🎜#

1. Établissez une connexion logicielle au programme php

ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

2 Modifier le fichier rc

1. Les variables d'environnement de l'utilisateur actuel

#如果是使用bash作为shell
vim ~/.bashrc
#增加一行环境变量
export PATH=/opt/remi/php74/root/usr/bin:$PATH
#刷新一下环境变量
source ~/.bashrc
#🎜. 🎜#2. Modifiez les variables d'environnement globales#🎜 🎜#
vim /etc/profile
export PATH=/opt/remi/php74/root/usr/bin:$PATH

Check PHP

Vérifiez si l'installation est réussie :

[root@VM-0-5-centos ~]# php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Le PHP installé ci-dessus n'installe que certaines extensions PHP, plus de logiciels peuvent être vus :

yum search php74

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer