LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 03-05-2010, 06:56 AM   #1
nicky77
LQ Newbie
 
Registered: Mar 2010
Posts: 16

Rep: Reputation: 0
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!
 
Old 03-05-2010, 07:15 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,975

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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

Last edited by bathory; 03-05-2010 at 03:45 PM. Reason: typo
 
Old 03-05-2010, 09:42 AM   #3
nicky77
LQ Newbie
 
Registered: Mar 2010
Posts: 16

Original Poster
Rep: Reputation: 0
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?
 
Old 03-05-2010, 10:05 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,975

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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.
 
Old 03-05-2010, 11:37 AM   #5
nicky77
LQ Newbie
 
Registered: Mar 2010
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 03-05-2010, 01:04 PM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,975

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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?
 
Old 03-05-2010, 03:22 PM   #7
nicky77
LQ Newbie
 
Registered: Mar 2010
Posts: 16

Original Poster
Rep: Reputation: 0
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.
 
Old 03-05-2010, 03:44 PM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,975

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
weird PHP compile issue- module shows in "php -m" but not in phpinfo call hbbtstar Linux - Software 1 08-28-2009 04:14 PM
can't connect php to mysql on RHEL5.0 in phpinfo page --without mysql is there vinayakbane Linux - Newbie 1 02-15-2009 12:47 AM
Compiling Apache, PHP and MySQL from source. Phr34Ck Linux - Software 6 02-29-2008 07:05 AM
Ubuntu amd64 (x86_64)version 7.04 issues with compiling php from source LDZ420 Linux - Software 5 08-23-2007 09:24 AM
PHP: Adding ffmpeg-php without re-compiling? vxc69 Linux - Software 2 05-17-2007 05:47 PM


All times are GMT -5. The time now is 03:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration