What do I need to change in order to change the default usr > local > lib > php install directory? Both the builds are to be compiled from source (something I am quite familiar with), and will not be from pre-configured packages.

I need to do this in order to allow me to build and run two seperate modules without any conflicts. - That part is not a problem, but trying to work out what to change in order to allow for the installs I need is.

I have just found a possible solution to this problem - no idea whether it will actually work with our setup yet, or whether it will work with both PHP5 and PHP6 but...

http://www.php.net/manual/en/configuration.changes.php

...is the link for anyone else with a similar problem.

Firstly, what Linux distro are you using? And in what format is the source in? rpm/deb/tar?

Thanks for the reply, nonshatter. I am glad that you replied because there is still one major problem that I overlooked in my first reply: namely that configuration change details will still leave me with the initial problem of getting PHP to install in different directories in the first place. - Anyway, to answer your question:

Linux: Debian Lenny (latest stable release), running as an unmodified image on a KVM VPS server.

Apache: apache2-mpm-prefork.deb apache2-prefork-dev.deb

PHP: intend to install 5.2.13 and 6.3.3 (one for a webstore that won't work with PHP 6 and the other for a personal project that may become a business project at a later date). - Both of these will be compiled from source.

I think that this is where the changes need to be made:

Directory and file names:

  --prefix=PREFIX         			install architecture-independent files in PREFIX [/usr/local]
  --exec-prefix=EPREFIX   			install architecture-dependent files in EPREFIX [same as prefix]
  --bindir=DIR            			user executables in DIR [EPREFIX/php53/bin]
  --sbindir=DIR           			system admin executables in DIR [EPREFIX/php53/sbin]
  --libexecdir=DIR        			program executables in DIR [EPREFIX/php53/libexec]
  --datadir=DIR           			read-only architecture-independent data in DIR [PREFIX/php53/share]
  --sysconfdir=DIR        			read-only single-machine data in DIR [PREFIX/php53/etc]
  --sharedstatedir=DIR    			modifiable architecture-independent data in DIR [PREFIX/php53/com]
  --localstatedir=DIR     			modifiable single-machine data in DIR [PREFIX/php53/var]
  --libdir=DIR            			object code libraries in DIR [EPREFIX/php53/lib]
  --includedir=DIR        			C header files in DIR [PREFIX/php53/include]
  --oldincludedir=DIR     			C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           			info documentation in DIR [PREFIX/info]
  --mandir=DIR            			man documentation in DIR [PREFIX/man]
  --srcdir=DIR            			find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX 			prepend PREFIX to installed program names
  --program-suffix=SUFFIX 			append SUFFIX to installed program names
  --program-transform-name=PROGRAM		run sed PROGRAM on installed program names

As you can see, it is a block of switches from the ./configure options. If I am not mistaken the changed switches (a number of them have had /php53 added to them) should mean that these switches will create a PHP installation that will run from usr > local > lib > php53

The add the above changes it would be necessary to add the following to ./configure:

Directory and file names:

  --bindir=EPREFIX/php53/bin
  --sbindir=EPREFIX/php53/sbin
  --libexecdir=EPREFIX/php53/libexec
  --datadir=PREFIX/php53/share
  --sysconfdir=PREFIX/php53/etc
  --sharedstatedir=PREFIX/php53/com
  --localstatedir=PREFIX/php53/var
  --libdir=EPREFIX/php53/lib
  --includedir=PREFIX/php53/include

which would be entered as:

./configure --bindir=EPREFIX/php53/bin --sbindir=EPREFIX/php53/sbin --libexecdir=EPREFIX/php53/libexec --datadir=PREFIX/php53/share --sysconfdir=PREFIX/php53/etc --sharedstatedir=PREFIX/php53/com --localstatedir=PREFIX/php53/var --libdir=EPREFIX/php53/lib --includedir=PREFIX/php53/include

Yes you're correct. I remember doing this on an old legacy system (SLES 9.3).

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql

Where prefix is the target installation directory, and the apxs2 switch is mandatory. But be wary, if you forget to add a specific module (e.g. php5-mysql, mod_ldap etc) at some point, then you'll have to go round the loop again (re-configure and re-make), adding the new switch options. I remember it being a bit of a pain to get all aspects of functionality to work!

Perhaps save your final configure command in a text file so you can refer back to it if you need to.

Hope that helps,
ns

Also:

--with-config-file-path=PREFIX/php53

Thanks, nonshatter. - Yes, I normally do use a text file to start with...

./configure --help >> HELP533

...and take it from there.


...and, yes, I see what you mean about the modules (thank-you). - Trying to identify and find all the dev libraries is an absolute pain too.

This method works for creating two (or more if need be) install directories, but fails when used to create seperate libraries for Apache. - The internal name of the generated .so files is the same even if the file name is changed and there is no way to alter this.

Apache documentation contains a totally useless article on how to use the APXS module to change such details ( http://httpd.apache.org/docs/2.0/programs/apxs.html ) complete with a PHP example that would never work in practice, but as the required switches cannot be passed during the PHP ./configure process both the functionality of the tool and the example are completely pointless.

This setup works, but ultimately fails because of segmentation faults when trying to start Apache (same items in each module being loaded into the same memory spaces I would guess):

makefile.global

libphp$(PHP_MAJOR_VERSION) -> change to libphp521


...then makefile

libphp$(PHP_MAJOR_VERSION) -> change to libphp521

mod_php5 -> change in makefile and change file name of php_5.c in the /sapi/apache2handler directory, also references in config.m4 config.w32, php.sym, php5apache2.dsp

php5_module -> change references in php_5.c, php_apache.h, and sapi_apache2.c

./configure --bindir=/usr/local/bin/521 --sbindir=/usr/local/sbin/521 --datadir=/usr/local/share/521 --sysconfdir=/usr/local/etc/521 --localstatedir=/var/local/521 --libdir=/usr/local/lib/521 --includedir=/usr/local/include/521 --with-apxs2=/usr/bin/apxs2 --enable-debug --with-config-file-path=/usr/local/521 --disable-short-tags --enable-dmalloc --with-openssl --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-mhash --enable-mbstring --with-libmbfl --with-mcrypt --with-mysql=/usr/bin --with-mysql-sock --with-mysqli=/usr/bin/mysql_config --enable-embedded-mysqli=/usr/bin/mysql_config --with-pdo-dblib --with-pdo-mysql --with-mm --enable-shmop --with-libxml-dir=/usr/lib --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-xsl --enable-zip --with-pear --with-pear=/usr/local/lib/521 --enable-zend-multibyte

...so it would seem that trying to run multiple versions of PHP on the same machine for use with Apache is possible, but it would be necessary to write some code to avoid memory space collisions. - I would test using different config options in each module but it seems that Apache is absolutely determined that multiple versions are not going to run and that is that, so the chances are good that, in doing so, I would be completely wasting my time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.