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

Final update.

The problem has been resolved.

The way I solve the problem is reinstalling Apache and PHP completely from source following the instructions in the following link.

Then make the extension by building the extension directly in PHP by following the instructions link below.

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

Thanks everyone, this is my first post on Stackoverflow and I spent all day making my first php extension. Although a little tough, I love it!: D

Original question

I am trying to build a php extension following the instruction from the following link:

I am building extension "rot13" in php using following steps

./configure --enable-rot13
sudo make install


Then I tested the extension using php command line. The result is exactly the same as in the article above.

I am assuming that after I build the extension in php, I do not 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 says nothing about the new extension, while the php -m command shows that my extension is loaded. I checked the apache2 log, no error.

For almost one day I was going for a walk and had no idea. Some threads are similar on stackoverflow but don't have real working solutions.

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

If you have any hints, please help. Thank!


I put extension = in php.ini file under path / etc / php 5 / apache2 / php.ini, but now when I restart 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 parameters must match in Unknown on line 0

Is there any information on what caused this error?

By the way, when I compile the extension, I used. / configure --enable-rot13 --with-php-config = / usr / local / bin / php-config to make sure it is using the PHP config file.

Update again:

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


source to share

1 answer

Ubuntu has 2 php.ini files, one for the CLI and one for apache.

By default, they are located in /etc/php5/cli/php.ini

and /etc/php5/apache2/php.ini


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



All Articles