apache2 & two php versions, how to use specific version

Hi all,

I have my Debian web server, where apache2 and php 5.2.0 are installed from debian package. It worked fine, both in CLI & Browser.

Recently i installed the php 5.2.9 from the source. To verify it i executed the "php --version" and it is showing 5.2.9 . But in the browser still it is showing the older version ?

Why apache2 will not take the newest php version by default ? And now how i can insist apache2 to use this php version ? Kindly guide me.

The version that is loaded by Apache is determined by the version that is seen by Apache, i.e. the one that is dumped in the Apache modules directory. If your installed version does not overwrite the one in that directory (presumably installed from the package tree), the distribution's version will be served.

Whether you can use your compiled version depends on whether your compile process has created a libphp5.so. If there is one, you can then try to overwrite and see if it works.

If you compile PHP as CLI or CGI, then you will not get that shared library. Then you will need to recompile your PHP. For details, please check the PHP manual for compilation hints.

Yes, you are right that the current compilation has not generated the libphp5.so, bcoz i did is

./configure
make && make install

which has not created any libphp5.so file.

So i tried doing,
./configure --with-apxs

I believe this is the way to create the libphp5.so ? Am i right in saying this ??

And while doing make i am facing the following error ?
make: *** [sapi/apache2handler/mod_php5.lo] Error 1

I searched, and tried hard to rectify the error and no progress in it.

---

Actually i have Debian Etch, where there is no package for the php 5.2.9 so i am installing from source which is making these issues ... Please help me solving the above issue, and guide me in installing 5.2.9 in Debian Etch 3.0 .

Any help is appreciated !

Any additional error messages above that line? I guess you may have omitted some. You should be quoting all the relevant error messages or no one will be able to help you. Thank you.

By the way, you probably want to try --with-apxs2 if you have Apache 2.

PHP: Apache 2.0 on Unix systems - Manual

Thanks for your time.

This is the command which i give in the dir "./php-5.2.9".

$ ./configure --with-apxs2

This got executed successfully and while executing make i face the following error,

In file included from /root/php-5.2.9/sapi/apache2handler/mod_php5.c:26:
/root/php-5.2.9/sapi/apache2handler/php_apache.h:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php5_module'
/root/php-5.2.9/sapi/apache2handler/php_apache.h:38: error: expected specifier-qualifier-list before 'apr_bucket_brigade'
/root/php-5.2.9/sapi/apache2handler/php_apache.h:51: error: expected ')' before '' token
/root/php-5.2.9/sapi/apache2handler/php_apache.h:52: error: expected ')' before '
' token
/root/php-5.2.9/sapi/apache2handler/php_apache.h:56: error: expected ')' before '*' token
/root/php-5.2.9/sapi/apache2handler/mod_php5.c:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'module'
make: *** [sapi/apache2handler/mod_php5.lo] Error 1

What could be the issue ?

This is unusual.

Are you sure you have run this from a clean source tree? That is, either you run a "make distclean" before you try "configure - make" again, or you try again with a source tree extracted fresh from tarball.

I still face the same error, i downloaded the source from php.net.

  1. Source Extracted:
    I extracted the source fresh from the tar ball.

  2. configure
    configured it as,

./configure --with-apxs2=/usr/bin/apxs
  1. make
    while executing make, the following is the last part of the error.
/bin/sh /root/sathiya/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/sathiya/php-5.2.9/meta_ccld  -IZend/ -I/root/sathiya/php-5.2.9/Zend/ -DPHP_ATOM_INC -I/root/sathiya/php-5.2.9/include -I/root/sathiya/php-5.2.9/main -I/root/sathiya/php-5.2.9 -I/usr/include/libxml2 -I/root/sathiya/php-5.2.9/ext/date/lib -I/root/sathiya/php-5.2.9/TSRM -I/root/sathiya/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/sathiya/php-5.2.9/Zend/zend_object_handlers.c -o Zend/zend_object_handlers.lo
/bin/sh /root/sathiya/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/sathiya/php-5.2.9/meta_ccld  -IZend/ -I/root/sathiya/php-5.2.9/Zend/ -DPHP_ATOM_INC -I/root/sathiya/php-5.2.9/include -I/root/sathiya/php-5.2.9/main -I/root/sathiya/php-5.2.9 -I/usr/include/libxml2 -I/root/sathiya/php-5.2.9/ext/date/lib -I/root/sathiya/php-5.2.9/TSRM -I/root/sathiya/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/sathiya/php-5.2.9/Zend/zend_objects_API.c -o Zend/zend_objects_API.lo
/bin/sh /root/sathiya/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/sathiya/php-5.2.9/meta_ccld  -IZend/ -I/root/sathiya/php-5.2.9/Zend/ -DPHP_ATOM_INC -I/root/sathiya/php-5.2.9/include -I/root/sathiya/php-5.2.9/main -I/root/sathiya/php-5.2.9 -I/usr/include/libxml2 -I/root/sathiya/php-5.2.9/ext/date/lib -I/root/sathiya/php-5.2.9/TSRM -I/root/sathiya/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/sathiya/php-5.2.9/Zend/zend_default_classes.c -o Zend/zend_default_classes.lo
/bin/sh /root/sathiya/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/sathiya/php-5.2.9/meta_ccld  -IZend/ -I/root/sathiya/php-5.2.9/Zend/ -DPHP_ATOM_INC -I/root/sathiya/php-5.2.9/include -I/root/sathiya/php-5.2.9/main -I/root/sathiya/php-5.2.9 -I/usr/include/libxml2 -I/root/sathiya/php-5.2.9/ext/date/lib -I/root/sathiya/php-5.2.9/TSRM -I/root/sathiya/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/sathiya/php-5.2.9/Zend/zend_execute.c -o Zend/zend_execute.lo
/bin/sh /root/sathiya/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/sathiya/php-5.2.9/meta_ccld  -DLINUX=22 -DEAPI -DTARGET="apache" -DHAVE_SET_DUMPABLE -DDB_DBM_HSEARCH=1 -DDEV_RANDOM=/dev/random -DUSE_HSREGEX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/apache-1.3   -Isapi/apache2handler/ -I/root/sathiya/php-5.2.9/sapi/apache2handler/ -DPHP_ATOM_INC -I/root/sathiya/php-5.2.9/include -I/root/sathiya/php-5.2.9/main -I/root/sathiya/php-5.2.9 -I/usr/include/libxml2 -I/root/sathiya/php-5.2.9/ext/date/lib -I/root/sathiya/php-5.2.9/TSRM -I/root/sathiya/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/sathiya/php-5.2.9/sapi/apache2handler/mod_php5.c -o sapi/apache2handler/mod_php5.lo
In file included from /root/sathiya/php-5.2.9/sapi/apache2handler/mod_php5.c:26:
/root/sathiya/php-5.2.9/sapi/apache2handler/php_apache.h:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php5_module'
/root/sathiya/php-5.2.9/sapi/apache2handler/php_apache.h:38: error: expected specifier-qualifier-list before 'apr_bucket_brigade'
/root/sathiya/php-5.2.9/sapi/apache2handler/php_apache.h:51: error: expected ')' before '*' token
/root/sathiya/php-5.2.9/sapi/apache2handler/php_apache.h:52: error: expected ')' before '*' token
/root/sathiya/php-5.2.9/sapi/apache2handler/php_apache.h:56: error: expected ')' before '*' token
/root/sathiya/php-5.2.9/sapi/apache2handler/mod_php5.c:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'module'
make: *** [sapi/apache2handler/mod_php5.lo] Error 1

It appears like it cannot find the apr/apr-utils header files. Please try to verify if the needed header packages have been installed.

Mabye you could try to install apache2 on debian etch using:

#apt-get install apache2

Then, install PHP5 support for apache2 on debian etch using:

#apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi

I installed all the above packages as mentioned.

I extracted fresh source. And i still get the same error !

/bin/sh /root/php-5.2.9/libtool --silent --preserve-dup-deps --mode=compile /root/php-5.2.9/meta_ccld  -DLINUX=22 -DEAPI -DTARGET="apache" -DHAVE_SET_DUMPABLE -DDB_DBM_HSEARCH=1 -DDEV_RANDOM=/dev/random -DUSE_HSREGEX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/apache-1.3   -Isapi/apache2handler/ -I/root/php-5.2.9/sapi/apache2handler/ -DPHP_ATOM_INC -I/root/php-5.2.9/include -I/root/php-5.2.9/main -I/root/php-5.2.9 -I/usr/include/libxml2 -I/root/php-5.2.9/ext/date/lib -I/root/php-5.2.9/TSRM -I/root/php-5.2.9/Zend  -D_REENTRANT  -I/usr/include -g -O2 -pthread -DZTS  -prefer-non-pic -c /root/php-5.2.9/sapi/apache2handler/mod_php5.c -o sapi/apache2handler/mod_php5.lo
In file included from /root/php-5.2.9/sapi/apache2handler/mod_php5.c:26:
/root/php-5.2.9/sapi/apache2handler/php_apache.h:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php5_module'
/root/php-5.2.9/sapi/apache2handler/php_apache.h:38: error: expected specifier-qualifier-list before 'apr_bucket_brigade'
/root/php-5.2.9/sapi/apache2handler/php_apache.h:51: error: expected ')' before '*' token
/root/php-5.2.9/sapi/apache2handler/php_apache.h:52: error: expected ')' before '*' token
/root/php-5.2.9/sapi/apache2handler/php_apache.h:56: error: expected ')' before '*' token
/root/php-5.2.9/sapi/apache2handler/mod_php5.c:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'module'
make: *** [sapi/apache2handler/mod_php5.lo] Error 1

Is there any other way to install php-5.2.9 in Debian Etch ?

Did you deinstall all prior versions before installing? It sounds like you might have a PATH conflict or similar problem.

Can you post your environmental variables?

  1. I uninstalled, and installed the php related packages. But there is no improvement, the same error occurs again.

  2. following is the environment variables..

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="1" [4]="release" [5]="i486-pc-linux-gnu")
BASH_VERSION='3.1.17(1)-release'
COLUMNS=141
DIRSTACK=()
EDITOR=vim
EUID=0
FCEDIT=vim
GROUPS=()
HISTFILE=/root/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/root
HOSTNAME=Debian-Server
HOSTTYPE=i486
IFS=$' \t\n'
LANG=en_IN
LINES=41
LOGNAME=root
LS_OPTIONS=--color=auto
MACHTYPE=i486-pc-linux-gnu
MAIL=/var/mail/root
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/bin/festival:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/lib/eclipse
PIPESTATUS=([0]="0" [1]="0")
PPID=429
PS1='\h:\w\$ '
PS2='> '
PS4='+ '
PWD=/root
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:histexpand:interactive-comments:monitor:vi
SHLVL=1
SSH_CLIENT='192.168.6.56 49231 22'
SSH_CONNECTION='192.168.6.56 49231 192.168.1.155 22'
SSH_TTY=/dev/pts/1
TERM=xterm
UID=0
USER=root

If you install with apt-get you don't need to configure/make because you are installing the binaries.

Isn't that right?

He probably wants to install the latest version. Debian's version is a bit old, though I think not too dated as to be intolerable.

If you dare to use Debian unstable (like I do on my desktop), you will get PHP 5.2.9 instead of 5.2.6 (with Debian Stable - Lenny) or 5.2.0 (Debian Stable - Etch). Then you will not only have bleeding edge PHP, you will always have the very latest version of essentially each and every package on your system if you upgrade often enough.

Managing a Debian Unstable system is tedious, though. Be forewarned.

You have really installed the APR/APRU header files (libaprutil1-dev and libapr1-dev)? They are not related to PHP, but Apache.

And, I think on Debian the apxs file is /usr/bin/apxs2. Are you sure you used the correct apxs?

You must have the package below installed, if you didn't compile install Apache yourself.

Debian -- Filelist of package apache2-prefork-dev/sid/i386

I tried installing the apache2-prefork-dev in Debian Etch. And it shows the following error.

apt-get install apache2-prefork-dev
....
The following packages have unmet dependencies:
  apache2-prefork-dev: Depends: libaprutil1-dev but it is not going to be installed
E: Broken packages

while trying to install that package,

apt-get install libaprutil1-dev
....
....
The following packages have unmet dependencies:
  libaprutil1-dev: Depends: libexpat1-dev but it is not going to be installed
                   Depends: libpcre3-dev but it is not going to be installed
                   Depends: libapr1-dev (>= 1.2.2-1) but it is not going to be installed
                   Depends: libsqlite3-dev but it is not going to be installed
                   Depends: libpq-dev but it is not going to be installed
                   Depends: libmysqlclient15-dev but it is not going to be installed
E: Broken packages

And it goes ... So what to do ?

It is your responsibility to find out why certain packages may not be installed on your system, as it may be due to conflicts with existing packages on your system that may prevent them from being installed.

The packages I mentioned are required if you need to compile anything related to Apache modules. You do not need them only if you are sure you have compiled and installed Apache from sources, and thus they are present although no binary package installed.

If you have such a broken system that would cost you a lot of time to fix to restore to working state, you may consider installing your self-compiled PHP as a CGI binary. That is not good in terms of performance (so refrain from doing so on a production machine), but you can be off the hassle associated with compiling Apache modules.

PHP: CGI and command line setups - Manual

I suggest you try to follow one of the guides to installing LAMP on Debian Etch, for example:


LAMP on Debian (Etch)

or

Install LAMP server in Debian, Ubuntu, and CentOS

or this older example:

The Perfect Setup - Debian Etch (Debian 4.0)

If you don't like those examples, you can Google for install lamp debian etch and find something that suits your requirements.

Thanks for all your time.

Thanks once again.

Finally, i upgraded my OS version from Debian Etch to Debian Lenny.

And installed php-5.2.9 from source, everything went fine. Following are the steps i followed,

  1. Installed apxs2 by installing the package,
    apt-get install apache2-prefork-dev

  2. configure
    ./configure --with-apxs2=/usr/bin/apxs2

  3. make & install
    make
    make install

It said simple errors in the fly, as packages missing and so. Solving it straight away made the php-5.2.9 available by both cli & in web front end.

Thanks for all who have helped in solving the issue.