could I install multiple version copy of php ?

You CAN have PHP 5.2 and 5.3 on the system. This trick will work with CustomBuild 1.2 (PHP5.2 as CLI and 5.3 as CGI (suPHP)):
Code:
cd /usr/local/directadmin/custombuild
./build set custombuild 1.2
./build update
mkdir -p custom/suphp
cp -pf configure/suphp/configure.php5 custom/suphp/configure.php6
perl -pi -e 's/php53/phprep/' versions.txt
perl -pi -e 's/php6/php53/' versions.txt
perl -pi -e 's/phprep/php6/' versions.txt
./build set php5_ver 5.2
./build set php6_cgi yes
./build set php5_cgi no
./build set php5_cli yes
#set php6-cgi (or cli) to yes in the options.conf
./build php n
mv -f /usr/local/php6 /usr/local/php6_old
ln -s /usr/local/php5 /usr/local/php6
Now PHP 5.3 will be installed as PHP6 in configuration files :)

this worked perfectly over the passed 2 years, but now i need to change to 5.3 default ald 5.2 for my users who don't have upgraded yet... what do i need to change to get that result?
 
Is it also possible to run php 5.2.x and php 5.3.x both in CGI/FastCGI for suPHP modus?

I try to setup this but only php 5.2.x works:

Code:
cd /usr/local/directadmin/custombuild
./build set custombuild 1.2
./build update
mkdir -p custom/suphp
cp -pf configure/suphp/configure.php5 custom/suphp/configure.php6
perl -pi -e 's/php53/phprep/' versions.txt
perl -pi -e 's/php6/php53/' versions.txt
perl -pi -e 's/phprep/php6/' versions.txt
./build set php5_ver 5.2
./build set php6_cgi yes
./build set php5_cgi yes
./build set php5_cli no
./build php n
mv -f /usr/local/php6 /usr/local/php6_old
ln -s /usr/local/php5 /usr/local/php6

I set a .htaccess into a user /public_html directory with code:

Code:
<FilesMatch "\.php$">
AddHandler x-httpd-php6 .php
</FilesMatch>

but nothing change to php 5.3.x ?
 
Output /usr/local/php6/bin/php -v

Code:
PHP 5.2.17 (cli) (built: Jul 31 2012 13:01:39)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.14, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies

This seems not oke, because it needs to be version 5.3.15?

Output /usr/local/php5/bin/php -v

Code:
PHP 5.2.17 (cli) (built: Jul 31 2012 13:01:39)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.14, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
 
Last edited:
Then you must be doing something wrong, I've never tried this solution, so I can't say what exactly is wrong... I did only with my own solution (and I could do it for you of course as a commerce service).

You should set

Code:
./build set clean no

and check config.log in all directories /usr/local/directadmin/custombuild/php-* after you build PHP.
 
Output /usr/local/php6/bin/php -v

Code:
PHP 5.2.17 (cli) (built: Jul 31 2012 13:01:39)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.14, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies

This seems not oke, because it needs to be version 5.3.15?

Output /usr/local/php5/bin/php -v

Code:
PHP 5.2.17 (cli) (built: Jul 31 2012 13:01:39)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.14, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
To me it looks as if the problem is that 5.2.17 is being installed in both places. Are you installing it last? Is either php5 or php6 a link to the other?

Jeff
 
@astra

Did you check config.log in all directories /usr/local/directadmin/custombuild/php-* after you build PHP? What ./configure lines contain there? It would be important to see prefix value from there.
 
5.3 default and 5.2 as option?

We'd like to configure the server so that php 5.3 fastcgi is default and php 5.2 is loaded as cli available through a .htaccess file. Pretty much reverse of what the guide in this thread is showing. :)

setup:
Code:
cd /usr/local/directadmin/custombuild
./build set custombuild 1.2
./build update
./build set autover no
cp -Rp configure custom
perl -pi -e 's/php5:/phprep:/' versions.txt
perl -pi -e 's/php6/php5/' versions.txt
perl -pi -e 's/phprep/php6/' versions.txt
./build set php5_ver 5.3
./build set php6_cgi yes
./build set php5_cgi yes
./build set php_cli no
./build php n

The compile process for both versions finishes successfully, but after that httpd seems to want to load /usr/lib/apache/libphp6.so because it's instructed to do so in /etc/httpd/conf/extra/httpd-phpmodules.conf, if I change:
Code:
LoadModule      php6_module             /usr/lib/apache/libphp6.so
to:
Code:
LoadModule      php5_module             /usr/lib/apache/libphp5.so
then httpd starts successfully, however I cannot figure out how to switch from the default 5.3 version to 5.2 using a .htaccess rule.

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler some-handler-goes-here .php
</FilesMatch>

Is there a way to get a list of available handlers in apache? Does anyone know which handler I need to use in order to switch to 5.2 cli?
 
You should check all files that have php in their names in directory /etc/httpd/conf/extra/



Your PHP 5.3 should be added here:
/usr/local/suphp/etc/suphp.conf

something like:

Code:
[handlers]
;Handler for php-scripts
x-httpd-php5="php:/usr/local/php5/bin/php-cgi"

and here

/etc/httpd/conf/extra/httpd-suphp.conf
Code:
<IfModule mod_suphp.c>
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler x-httpd-php4 .php4
AddHandler x-httpd-php5 .inc .php .php3 .php5 .phtml
</FilesMatch>
<Location />
suPHP_Engine on
suPHP_ConfigPath /usr/local/etc/php5/cgi/
suPHP_AddHandler x-httpd-php5
</Location>
</IfModule>

and make sure, you've got this commented in /etc/httpd/conf/extra/httpd-php-handlers.conf:

Code:
#<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
#AddHandler application/x-httpd-php .inc .php .php3 .php4 .php5 .php6 .phtml
#AddHandler application/x-httpd-php-source .phps
#</FilesMatch>
AddType text/html .php

To use php 5.2. you'll need to add into .htaccess:

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler application/x-httpd-php .inc .php .php3 .php4 .php5 .php6 .phtml
AddHandler application/x-httpd-php-source .phps
</FilesMatch>


P.S. Note, I did not check it myself, so it's up to you to test it and confirm that it is working.
 
Howto build php 5.3.x (cgi) 5.2.x (cli)

This is the config I ended up with (cloudlinux option is optional by the way):

installation
Code:
cd /usr/local/directadmin/custombuild
./build set custombuild 1.2
./build update
./build set autover no
cp -Rp configure custom
cp -pf configure/suphp/configure.php5 custom/suphp/configure.php6
perl -pi -e 's/php5:/phprep:/' versions.txt
perl -pi -e 's/php6/php5/' versions.txt
perl -pi -e 's/phprep/php6/' versions.txt
./build set cloudlinux yes
./build set php5_ver 5.3
./build set php6_cgi no
./build set php6_cli yes
./build set php5_cgi yes
./build set php5_cli no
./build php n

After the build script finishes, it tries to restart apache, but can't because libphp6.so cannot be found, this is likely because the build script has libphp6.so hardcoded somewhere and because we're using that to cheat our way through this procedure, we can use sed to fix it;
Code:
sed -i 's/php6/php5/g' /etc/httpd/conf/extra/httpd-phpmodules.conf
service httpd restart

switching using a .htaccess
Switching from the default can now be done with a .htaccess in a users' public_html dir.
Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
SetHandler application/x-httpd-php
</FilesMatch>

ioncube loader
If you also want to add ioncube support to the 5.2 module, you need a workaround in order to be able to build ioncube as well.

Code:
./build set php6_cli no && ./build ioncube && ./build php6_cli yes
ionCube loader has been installed.
cp /usr/local/directadmin/custombuild/ioncube/ioncube_loader_lin_5.2.so /usr/local/lib/
echo "zend_extension=/usr/local/lib/ioncube_loader_lin_5.2.so" >> /usr/local/lib/php.ini

using pecl
Setting up pecl is easy too, just need to point it to the right config file:
Code:
/usr/local/bin/pecl config-set php_ini /usr/local/lib/php.ini
/usr/local/bin/pear config-set php_ini /usr/local/lib/php.ini
/usr/local/php5/bin/pear config-set php_ini /usr/local/etc/php5/cgi/php.ini
/usr/local/php5/bin/pecl config-set php_ini /usr/local/etc/php5/cgi/php.ini

Then you can use either pecl to install modules like apc, imagemagick, etc.

final result
Code:
/usr/local/bin/php -v
PHP 5.2.17 (cli) (built: Sep  4 2012 16:43:01)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.

/usr/local/php5/bin/php -v
PHP 5.3.16 (cli) (built: Sep  4 2012 16:46:05)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.
 
Sure, but it's not quite that simple.

How do you plan on calling PHP? As a cgi program? Or through Apache? And if through Apache, how do you intend to tell apache to use different modules for PHP? My understanding is that apache can only be compiled with one php module, which limits you to two versions: one using mod_php for a specific version, and another using CGI. Am I wrong?

And don't forget that when you compile PHP you need to put different versions in different paths, so each subsequent install won't overwrite the previous one.

And that you'll need to rename them as well, as otherwise just calling php will simply call the first one your system finds in it's path.

Jeff
 
Your just asking for problems if you install 5.2 anymore. It has been EOL for a long time now.
 
My understanding is that apache can only be compiled with one php module, which limits you to two versions: one using mod_php for a specific version, and another using CGI. Am I wrong?

When using suPHP you can even install all previously released PHP versions, that's piece of a cake, if to do with a light manual modifications of:

/usr/local/directadmin/custombuild/custom/suphp/configure.php5
/usr/local/suphp/etc/suphp.conf
/etc/httpd/conf/extra/httpd-suphp.conf
 
Try to setup PHP 5.2 and 5.3 as per guide, but going wrong somewhere.

Originally custombuild 1.1 and php 5.2, installed custombuild 1.2 and followed guide at top of thread.

From options.conf:
Code:
default_php=5
php5_ver=5.2
php5_cli=yes
php5_cgi=no
php6_cli=no
php6_cgi=yes
php_ini=no

/usr/local/bin/php is version 5.2.17
/usr/local/php5/bin/php is 5.3.28

phpinfo gives 5.2.17

using .htaccess:
Code:
<FilesMatch "\.php$">
AddHandler x-httpd-php6 .php
</FilesMatch>

gives HTTP 500 error

Any pointers or suggestions gratefully received.

Thanks
 
try
AddHandler x-httpd-php .php

Try to setup PHP 5.2 and 5.3 as per guide, but going wrong somewhere.

Originally custombuild 1.1 and php 5.2, installed custombuild 1.2 and followed guide at top of thread.

From options.conf:
Code:
default_php=5
php5_ver=5.2
php5_cli=yes
php5_cgi=no
php6_cli=no
php6_cgi=yes
php_ini=no

/usr/local/bin/php is version 5.2.17
/usr/local/php5/bin/php is 5.3.28

phpinfo gives 5.2.17

using .htaccess:
Code:
<FilesMatch "\.php$">
AddHandler x-httpd-php6 .php
</FilesMatch>

gives HTTP 500 error

Any pointers or suggestions gratefully received.

Thanks
 
Back
Top