Compiling PHP 5.1.6 from source - php -v and phpinfo() version discrepancy
Hi, I have just bought a VPS running Ubuntu and I need to install the LAMP stack with PHP 5.1.6. The VPS came with no PHP installed (checked this from the shell with php -v) and with Apache/2.2.12 installed. I installed PHP 5.1.6 from source and compiled it with Apache 2.2 (using libapache2-mod-php5), tried a phpinfo() test which worked fine, however, phpinfo() shows the PHP version as 5.2.1 (with JSON enabled), whereas running php-v in the shell shows as 5.1.6. Anyone any ideas what might be happening here? I need to ensure I am running PHP 5.1.6.
Thanks in advance for any help! |
Quote:
You didn't mention the options used to compile php, but you should have used "--with-apxs2=/path/to/apxs" in the ./configure script of php. This way the compiled php5_module will use the correct php. Regards |
Thanks bathory, you're right - I didn't specify any options during configuration. I ran ./configure again using "--with-apx2=/path/to/apxs" - but after restarting apache i still have PHP 5.2.1 showing. Do i have to remove the libapache2-mod-php5 module (not sure how to do this other than reinstalling apache) and rerun ./configure?
|
I guess you've run "make && make install" after ./configure.
In that case you can manually copy libphp5.so to the location where your apache looks for its modules. You can find libphp5.so in the subdir libs/ in the directory you built php. The apache modules location can be found from the LoadModule directive in httpd.conf. Then add: Code:
LoadModule php5_module /path/to/apache/modules/libphp5.so |
Yes, I ran make and make install. However, I can only find one libphp5.so file and it's in /usr/lib/apache2/modules/libphp5.so - which is what Apache is already loading, so if i understand correctly this is the one i want to replace - but i can't find the correct libphp5.so to replace it with. Running find / -name libphp5.so only gives the one result.
Thanks again for your help bathory and apologies if this is utterly basic stuff i'm getting stuck with! |
It should be there. Actually libphp5.so should be present in 2 subdirectories: libs/ and .libs/, so I guess the the module is not built.
Are you sure make finished without errors? Could you run Code:
make distclean |
Ok, I ran make distclean, the following for configure:
Code:
./configure --with-apx2=/path/to/apxs Code:
Build complete. Code:
Installing PHP SAPI module: cgi It looks like Apache is still using PHP version 5.2.1 which Ubuntu bundles with the apache php module. |
Oups, I've made a typo and you didn't notice it also. It's "--with-apxs2=/path/to/apxs" (note also that you have to replace /path/to with the actual path to apxs).
Please also note, that you might need mysql support (it's a LAMP after all) and perhaps support for other things, so your ./configure must contain these options. Since the old phpinfo() still works, take a look at the beginning of it to have an idea of what was added to the old php. Sorry for the mistake Rgrds |
All times are GMT -5. The time now is 07:23 AM. |