Was soll ich tun, wenn die PHP-Erweiterung nicht angezeigt wird?

藏色散人
Freigeben: 2023-03-10 16:52:02
Original
4026 Leute haben es durchsucht

Der Grund, warum die PHP-Erweiterung nicht angezeigt wird, liegt darin, dass php.ini beim Start von php-fpm nicht angegeben ist. Die Lösung besteht darin, die Datei php.ini anzugeben, um den Dienst „php-fpm“ zu starten.

Was soll ich tun, wenn die PHP-Erweiterung nicht angezeigt wird?

Die Betriebsumgebung dieses Artikels: Linux5.9.8-System, PHP5.6-Version, DELL G3-Computer

Was soll ich tun, wenn die PHP-Erweiterung nicht angezeigt wird?

Die Gründe und Lösungen dafür, dass ein Neustart von PHP nach der Installation von Erweiterungsmodulen nicht wirksam wird

In der LNMP-Betriebs- und Wartungsumgebung stellen wir häufig fest, dass einige PHP-abhängige Erweiterungsmodule nicht installiert sind, was ein späteres Hinzufügen dieser Erweiterungsmodule erfordert. Nachdem die Erweiterungen installiert und konfiguriert wurden, werden Sie häufig feststellen, dass diese Erweiterungen nach dem Neustart des PHP-FPM-Dienstes nicht wirklich geladen werden! Das Folgende ist ein Beispiel zur Veranschaulichung:

Beispielumgebung:

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
Nach dem Login kopieren

Mit dem Befehl php -m wird festgestellt, dass die Erweiterungen bcmath und gettest fehlen.

[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 ~]#
Nach dem Login kopieren

Jetzt beginnen Sie mit der Installation von bcmatn und gettest Erweiterungen

安装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!?
Nach dem Login kopieren

Das liegt daran, dass php.ini beim Start von php-fpm nicht angegeben wurde und daher nie wirksam wurde!

[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 ~]#
Nach dem Login kopieren

Empfohlenes Lernen: „PHP-Video-Tutorial

Das obige ist der detaillierte Inhalt vonWas soll ich tun, wenn die PHP-Erweiterung nicht angezeigt wird?. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Verwandte Etiketten:
php
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!