Que dois-je faire si l'extension php ne s'affiche pas ?

藏色散人
Libérer: 2023-03-10 16:52:02
original
4026 Les gens l'ont consulté

La raison pour laquelle l'extension php ne s'affiche pas est que php.ini n'est pas spécifié au démarrage de php-fpm. La solution est de spécifier le fichier php.ini pour démarrer le service "php-fpm".

Que dois-je faire si l'extension php ne s'affiche pas ?

L'environnement d'exploitation de cet article : système linux5.9.8, PHP version 5.6, ordinateur DELL G3

Que dois-je faire si le php le poste ne s'affiche pas ?

Après que PHP ait installé le module d'extension, les raisons et les solutions de redémarrage n'ont pas pris effet

Dans l'environnement d'exploitation et de maintenance de lnmp, nous constatons souvent que certains modules d'extension dont dépend PHP ne le sont pas installé, ce qui nécessite Ces modules d'extension seront ajoutés 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 :

php安装包存放路径:/data/software/php-5.6.10.tar.gz
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

A l'aide de la commande php -m, on constate que les bcmath et Les extensions 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

Maintenant, commencez à installer bcmatn et les extensions gettest

安装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
.......
编译成功之后会告诉你一个目录
Installing shared extensions:     /data/php/lib/php/extensions/no-debug-non-zts-20131226
 
安装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
.......
编译成功之后会告诉你一个目录
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
总用量 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

配置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
 
重启php-fpm
[root@zabbix ~]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
 
然后再次查看bcmath和gettext扩展安装后,是否生效?
[root@zabbix ~]# php -m|grep bcmath
[root@zabbix ~]# php -m|grep gettext
[root@zabbix ~]#
 
发现并没有生效! why!?
Copier après la connexion

C'est parce que lorsque php-fpm démarré, php n'était pas spécifié .ini, 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

解决办法:
1)指定php.ini文件来启动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

2)要是上面启动后,安装的php扩展还是没有生效!那就可能是php.ini文件没有放对路径(这里我是直接放大php的etc目录下的)
[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

然后再接着重启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 ~]# 

最后再次查看bcmath和gettext扩展有没有生效?
[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:php.cn
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!