Comment installer PHP7 sur Linux Centos

WBOY
Libérer: 2023-05-15 20:16:04
avant
1957 Les gens l'ont consulté

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
Copier après la connexion

2. Source REMI# 🎜🎜#

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Copier après la connexion

3. Installez l'outil de gestion des sources Yum

yum -y install yum-utils
Copier après la connexion

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
Copier après la connexion
#🎜. 🎜#2 .Redémarrez l'ordinateur, sinon vous ne pourrez peut-être pas démarrer php

reboot
Copier après la connexion

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

systemctl start php74-php-fpm
systemctl enable php74-php-fpm
Copier après la connexion

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
Copier après la connexion

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
Copier après la connexion
.

3. Recherchez l'emplacement du php .ini :

[root@localhost src]# find /etc/opt/remi/php74 -name php.ini/etc/opt/remi/php74/php.ini
Copier après la connexion

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
Copier après la connexion
#🎜 🎜#5. Redémarrez php74-php-fpm

systemctl restart php74-php-fpm
Copier après la connexion

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 #检查状态
Copier après la connexion

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
Copier après la connexion

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
Copier après la connexion
#🎜. 🎜#2. Modifiez les variables d'environnement globales#🎜 🎜#
vim /etc/profile
export PATH=/opt/remi/php74/root/usr/bin:$PATH
Copier après la connexion

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
Copier après la connexion

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

yum search php74
Copier après la connexion

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!

Étiquettes associées:
source:yisu.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!