Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP extension loaded in command line (cli) but not loaded by apache

Final Update.

Problem Solved.

The way I solve the problem is re-install Apache and PHP entirely from source following the instruction by the following link.

http://dan.drydog.com/apache2php.html

Then do the extension by build the extension directly into PHP following the instruction by the link down below.

The only thing is that the binaries are all only in the specific path, which I think is a easy problem to solve though.

Thanks everyone, this is my first post in Stackoverflow and I spend one whole day to make my first php extension. Though a little bit tough, but I like it! :D

Original Question

I'm trying to build a php extension following the instruction by the following link:

http://docstore.mik.ua/orelly/webprog/php/ch14_03.htm

I build the extension of 'rot13' into the php using the following steps

./buildconf
./configure --enable-rot13
make
sudo make install

Then I tested the extension by the command line php. The output is exactly the same as the above article.

I suppose after I build the extension into php itself, I don't need to care about the php.ini file. Then I try to test the extension in the browser, I find out that the phpinfo() page doesn't show any thing about the new extension whereas php -m command shows my extension is loaded. I checked the apache2 log, there is no error.

I googled for nearly one day and got no clue. Some threads are similar in stackoverflow but no real working solutions.

My system is Ubuntu 11.10 and php 5.3.10 and apache2.2.20.

If you guys have clues, please help. Thanks!

Update:

I did put the extension=rot13.so in the php.ini file at the path of /etc/php5/apache2/php.ini but now whenever I restart the apache2 server, I got the following error.

PHP Warning:  PHP Startup: rot13: Unable to initialize module
Module compiled with build ID=API20090626,TS,debug
PHP compiled with build ID=API20090626,NTS

These options need to match in Unknown on line 0

Any one has any clue about what caused this fault?

BTW, when I compile the extension, I did use the ./configure --enable-rot13 --with-php-config=/usr/local/bin/php-config to make sure it uses the configuration file of php.

Update again:

I find out that the phpinfo() from the web page has different version of php -i I get from the command line... How strange is that? I'll try to google how to figure out this conflict.

like image 973
Tao Zhou Avatar asked Oct 30 '25 14:10

Tao Zhou


1 Answers

In Ubuntu, there are 2 php.ini files, one for CLI and one for apache.

By default, they are located at /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini.

In your case, you need to enable the extension in apache2 php.ini file too.

like image 124
Hakan Deryal Avatar answered Nov 02 '25 04:11

Hakan Deryal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!