Comment résoudre le problème selon lequel l'installation de l'extension php ne prend pas effet ?

青灯夜游
Libérer: 2023-04-08 16:22:01
avant
2456 Les gens l'ont consulté

Comment résoudre le problème selon lequel l'installation de l'extension PHP ne prend pas effet ? L'article suivant vous présentera comment résoudre le problème de l'installation de l'extension PHP qui ne prend pas effet. Il a une certaine valeur de référence. Les amis dans le besoin peuvent s'y référer. J'espère qu'il sera utile à tout le monde.

Comment résoudre le problème selon lequel l'installation de l'extension php ne prend pas effet ?

La raison pour laquelle le redémarrage de PHP ne prend pas effet après l'installation du module d'extension et de la solution

Dans l'environnement d'exploitation et de maintenance lnmp, nous rencontrons souvent certains Dépendances PHP Les modules d'extension ne sont pas installés, ce qui nécessite d'ajouter ces modules d'extension ultérieurement. Une fois les extensions installées et configurées, vous constaterez souvent qu'après le redémarrage du service php-fpm, ces extensions ne sont pas réellement chargées ! Voici un exemple pour illustrer :

Exemple d'environnement :

chemin de stockage du package d'installation php : /data/software/php-5.6.10.tar.gz

répertoire d'installation php : /data/php

[root@zabbix ~]# ll /data/software/php-5.6.10.tar.gz
-rw-r--r-- 1 root root 18306403 6月 11 2015 /data/software/php-5.6.10.tar.gz
[root@zabbix ~]# ll -d /data/software/php-5.6.10
drwxr-xr-x 17 www www 4096 10月 13 19:38 /data/software/php-5.6.10
[root@zabbix ~]# ls /data/php/
bin etc include lib php sbin var
Copier après la connexion

Utilisez la commande php -m et constatez que les extensions bcmath et gettest sont manquantes

[root@zabbix ~]# vim /etc/profile
export PATH=$PATH:/data/php/bin
[root@zabbix ~]# source /etc/profile
[root@zabbix ~]# php -m|grep bcmath
[root@zabbix ~]# php -m|grep gettext
[root@zabbix ~]#
Copier après la connexion

Commencez maintenant à installer les extensions bcmatn et gettest

Installez le extension bcmath

[root@zabbix ~]# cd /data/software/php-5.6.10/ext/bcmath/
[root@zabbix bcmath]# /data/php/bin/phpize
[root@zabbix bcmath]# ./configure --with-php-config=/data/php/bin/php-config
[root@zabbix bcmath]# make && make
.......
Copier après la connexion

Une fois la compilation réussie, il vous indiquera un répertoire

Installing shared extensions:   /data/php/lib/php/extensions/no-debug-non-zts-20131226
Copier après la connexion

Installez l'extension gettext

[root@zabbix ~]# cd /data/software/php-5.6.10/ext/gettext/
[root@zabbix gettext]# /data/php/bin/phpize
[root@zabbix gettext]# ./configure --with-php-config=/data/php/bin/php-config
[root@zabbix gettext]# make && make
.......
Copier après la connexion

Après le la compilation est réussie, il vous indiquera un répertoire

Installing shared extensions:   /data/php/lib/php/extensions/no-debug-non-zts-20131226
[root@zabbix ~]# ll /data/php/lib/php/extensions/no-debug-non-zts-20131226
Copier après la connexion

Utilisation totale 2336

-rwxr-xr-x 1 root root 380152 10月 13 23:03 bcmath.so
-rwxr-xr-x 1 root root  50376 10月 13 23:31 gettext.so
Copier après la connexion

Configurer php.ini

[root@zabbix ~]# vim /data/php/etc/php.ini
.........
extension_dir = "/data/php/lib/php/extensions/no-debug-non-zts-20131226"
extension=bcmath.so
extension=gettext.so
Copier après la connexion

Redémarrer php-fpm

[root@zabbix ~]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
Copier après la connexion

Puis vérifier à nouveau si les extensions bcmath et gettext ont pris effet après l'installation ?

[root@zabbix ~]# php -m|grep bcmath
[root@zabbix ~]# php -m|grep gettext
[root@zabbix ~]#
Copier après la connexion

J'ai découvert que ça ne fonctionnait pas ! Pourquoi! ?

C'est parce que php.ini n'a pas été spécifié au démarrage de php-fpm, donc il n'a jamais pris effet !

[root@zabbix etc]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@zabbix etc]# ps -ef|grep php-fpm
root   19529   1 0 23:37 ?    00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf)
www   19530 19529 0 23:37 ?    00:00:00 php-fpm: pool www
www   19531 19529 0 23:37 ?    00:00:00 php-fpm: pool www
root   19533 17173 0 23:37 pts/4  00:00:00 grep --color=auto php-fpm
Copier après la connexion

Solution :

1) Spécifiez le fichier php.ini pour démarrer le service php-fpm

[root@zabbix etc]# /etc/init.d/php-fpm stop
Gracefully shutting down php-fpm . done
[root@zabbix etc]# ps -ef|grep php-fpm
root   19541 17173 0 23:38 pts/4  00:00:00 grep --color=auto php-fpm
[root@zabbix etc]# /data/php/sbin/php-fpm -y /data/php/etc/php-fpm.conf -c /data/php/etc/php.ini
[root@zabbix etc]# ps -ef|grep php-fpm
root   19543   1 0 23:38 ?    00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf)
www   19544 19543 0 23:38 ?    00:00:00 php-fpm: pool www
www   19545 19543 0 23:38 ?    00:00:00 php-fpm: pool www
root   19547 17173 0 23:39 pts/4  00:00:00 grep --color=auto php-fpm
Copier après la connexion

2) Si ce qui précède est démarré , installez L'extension php ne prend toujours pas effet ! Ensuite il se peut que le fichier php.ini ne soit pas placé dans le bon chemin (ici j'agrandis directement le répertoire etc de php)

[root@zabbix ~]# ll /data/php/etc/php.ini
-rw-r--r-- 1 root root 73243 10月 13 23:32 /data/php/etc/php.ini
[root@zabbix ~]# cp /data/php/etc/php.ini /data/php/lib/
[root@zabbix ~]# ll /data/php/lib/php.ini
-rw-r--r-- 1 root root 73243 10月 13 23:35 /data/php/lib/php.ini
Copier après la connexion

Puis redémarrez le service php-fpm !

[root@zabbix ~]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@zabbix ~]# ps -ef|grep php
root   19564   1 0 23:43 ?    00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf)
www   19565 19564 0 23:43 ?    00:00:00 php-fpm: pool www
www   19566 19564 0 23:43 ?    00:00:00 php-fpm: pool www
root   19568 17173 0 23:43 pts/4  00:00:00 grep --color=auto php
[root@zabbix ~]#
Copier après la connexion

Vérifiez enfin à nouveau si les extensions bcmath et gettext ont pris effet ?

[root@zabbix ~]# php -m|grep bcmath
bcmath
[root@zabbix ~]# php -m|grep gettext
gettext
[root@zabbix ~]#
Copier après la connexion

Apprentissage recommandé : Tutoriel vidéo PHP

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:
php
source:w3xue
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!