Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that php extension doesn't work?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to solve the problem that php extension does not take effect". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The solution that php extension does not take effect: 1, specify php.ini file to start php-fpm service; 2, modify the path of php.ini file; 3, restart php-fpm service.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

What if php extension doesn't work?

Resolve the problem that the php extension installation does not take effect

The reason why the restart does not take effect after installing the expansion module in php and its solution

In the lnmp operation and maintenance environment, we often encounter some extension modules that php depends on are not installed, so we need to add these extension modules later. After the extensions are installed and configured, you will often find that after the php-fpm service is restarted, these extensions are not really loaded! The following is illustrated by an example:

Sample environment:

Php installation package storage path: / data/software/php-5.6.10.tar.gz

Php installation directory: / data/php

[root@zabbix ~] # ll / data/software/php-5.6.10.tar.gz-rw-r--r-- 1 root root 18306403 June 11 2015 / data/software/php-5.6.10.tar.gz [root@zabbix] # ll-d / data/software/php-5.6.10drwxr-xr-x 17 www www 4096 October 13 19:38 / data/software/php-5.6.10 [root@zabbix] # ls / data/php/bin etc include lib php sbin var

Using the php-m command, bcmath and gettest extensions were found missing

[root@zabbix ~] # vim / etc/profileexport PATH=$PATH:/data/php/bin [root@zabbix ~] # source / etc/profile [root@zabbix ~] # php-m | grep bcmath [root@zabbix ~] # php-m | grep gettext [root@zabbix ~] #

Now start installing the bcmatn and gettest extensions

Install the bcmath extension

[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.

I will tell you a directory when the compilation is successful.

Installing shared extensions: / data/php/lib/php/extensions/no-debug-non-zts-20131226

Install the gettext extension

[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.

I will tell you a directory when the compilation is successful.

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

The total dosage is 2336

-rwxr-xr-x 1 root root 380152 October 13 23:03 bcmath.so-rwxr-xr-x 1 root root 50376 October 13 23:31 gettext.so

Configure php.ini

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

Restart php-fpm

[root@zabbix] # / etc/init.d/php-fpm restartGracefully shutting down php-fpm. DoneStarting php-fpm done

Then check the installation of the bcmath and gettext extensions again, does it take effect?

[root@zabbix ~] # php-m | grep bcmath [root@zabbix ~] # php-m | grep gettext [root@zabbix ~] #

It didn't work! Why!?

This is because when php-fpm starts, no php.ini is specified, so it never works!

[root@zabbix etc] # / etc/init.d/php-fpm restartGracefully shutting down php-fpm. DoneStarting php-fpm done [root@zabbix etc] # ps-ef | grep php-fpmroot 19529 1 0 23:37? 00:00:00 php-fpm: master process (/ data/php/etc/php-fpm.conf) www 19530 19529 23:37? 00:00:00 php-fpm: pool wwwwww 19531 19529 0 23:37? 00:00:00 php-fpm: pool wwwroot 19533 17173 0 23:37 pts/4 00:00:00 grep-- color=auto php-fpm

Solution:

1) specify the php.ini file to start the php-fpm service

[root@zabbix etc] # / etc/init.d/php-fpm stopGracefully shutting down php-fpm. Done [root@zabbix etc] # ps-ef | grep php-fpmroot 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-fpmroot 19543 10 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 wwwwww 19545 19543 0 23:38? 00:00:00 php-fpm: pool wwwroot 19547 17173 0 23:39 pts/4 00:00:00 grep-- color=auto php-fpm

2) if the above startup, the installation of php extension still does not take effect! Then it may be that the php.ini file is not in the right path (here I am directly zooming in on the etc directory of php)

[root@zabbix ~] # ll / data/php/etc/php.ini-rw-r--r-- 1 root root 73243 October 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 October 13 23:35 / data/php/lib/php.ini

Then restart the php-fpm service!

[root@zabbix] # / etc/init.d/php-fpm restartGracefully shutting down php-fpm. DoneStarting php-fpm done [root@zabbix ~] # ps-ef | grep phproot 19564 10 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 wwwwww 19566 19564 0 23:43? 00:00:00 php-fpm: pool wwwroot 19568 17173 0 23:43 pts/4 00:00:00 grep-- color=auto php [root@zabbix ~] #

Finally, check again to see if the bcmath and gettext extensions are in effect?

[root@zabbix ~] # php-m | grep bcmathbcmath [root@zabbix ~] # php-m | grep gettextgettext [root@zabbix ~] # this is the end of the introduction of "how to solve the problem that php extension does not take effect". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report