LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Compiling PHP 5.1.6 from source - php -v and phpinfo() version discrepancy (http://www.linuxquestions.org/questions/linux-software-2/compiling-php-5-1-6-from-source-php-v-and-phpinfo-version-discrepancy-793372/)

nicky77 03-05-2010 05:56 AM

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!

bathory 03-05-2010 06:15 AM

Quote:

I installed PHP 5.1.6 from source and compiled it with Apache 2.2 (using libapache2-mod-php5),
I guess that apache uses the php module from libapache2-mod-php5, that's why you get the wrong version.
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

nicky77 03-05-2010 08:42 AM

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?

bathory 03-05-2010 09:05 AM

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
There is no need to uninstall anything, just comment out the LoadModule that loads the wrong php_module.

nicky77 03-05-2010 10:37 AM

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!

bathory 03-05-2010 12:04 PM

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
and redo the procedure, posting here the whole ./configure command you use and the last couple of lines of make?

nicky77 03-05-2010 02:22 PM

Ok, I ran make distclean, the following for configure:
Code:

./configure --with-apx2=/path/to/apxs
Then the last few lines of make are as follows (this has been the same each time i've tried):
Code:

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

When running make install, I get the following:
Code:

Installing PHP SAPI module:      cgi
Installing PHP CGI into: /usr/local/bin/
Installing build environment:    /usr/local/lib/php/build/
Installing header files:          /usr/local/include/php/
Installing helper programs:      /usr/local/bin/
  program: phpize
  program: php-config
Installing man pages:            /usr/local/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/lib/php/
[PEAR] Archive_Tar    - already installed: 1.3.1
[PEAR] Console_Getopt - already installed: 1.2
[PEAR] PEAR          - already installed: 1.4.9
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
Installing PDO headers:          /usr/local/include/php/ext/pdo/

Then, "find / -name libphp5.so" just returns /usr/lib/apache2/modules/libphp5.so

It looks like Apache is still using PHP version 5.2.1 which Ubuntu bundles with the apache php module.

bathory 03-05-2010 02:44 PM

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 01:59 AM.