简体   繁体   中英

PHP don't load extension

I wrote my extension.

Ubuntu system.

php -c "/etc/php5/apache2/php.ini" -r "echo extension_loaded('my');"
 => 1 OK!

But under apache - nothing!

echo extension_loaded('my'); 
=> "" 

Why?

Php ini shows:

" Loaded Configuration File /etc/php5/apache2/php.ini"

I always put my extensions in separate files and place them inside

/etc/php5/apache2/conf.d/

suppose I wanted to load mongo php extension, i would perform the following steps:

sudo pecl install mongo

and once that is completed successfully, I would make a

echo "extension=mongo.so" | sudo tee /etc/php5/apache2/conf.d/mongo.ini

after that I would reload or restart the server

sudo service apache2 restart

I got the same problem, and I think the issue is what the extension path is relative to when running under apache.

The default setting

extension_dir = "ext"
works in CLI because PHP is called directly.

When running under apache i got it to work when specified the absolute path with forward slashes:

 extension_dir = "c:/php/ext"  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM