Install an old PHP version for one site (domain)

babipanghang

New member
Joined
Jul 20, 2014
Messages
4
Good afternoon,

I have a directadmin server running with php5.6 mod_php as primary, and php 7.0 php-fpm as secondary. However, there's one domain that needs to support php 5.3 for compatibility reasons. What would be the best way to go about this?

Thanks
 
Hello,

If you use CloudLinux OS based on CentOS then you could use their selector and enable PHP 5.3 for your domain.

If you don't use CloudLinux then there won't be any simple way to achieve the desired. You need to know Directadmin from inside and do a lot of manual work for it.

You could try to build PHP-FPM 5.3 with custombuild as the second PHP instance, and without rewriting Apache configs switch PHP version back to 7.0 in options file.

So it will be something:

1. Build PHP 5.3 with custombuild (as the secondary PHP or with expert mode)
2. Enable PHP-FPM 53 configs (manually or with custombuild)
3. Enable autostart for PHP-FPM 53 at boot time.
4. Customize httpd.conf and/or .htaccess to attach your site to PHP-FPM 53.

I posted here a raw idea on how to set it up. Currently I don't have a detailed how-to so that's up to you to find out details for each of the steps. I did the same with suPHP, fastcgi only on my end.
 
Thanks, but that sounds awfully risky for a production server (since you don't know what may get messed up doint this with custombuild).

I've decided to try a similar path, but one with less possibly system-wide implications, but have still some trouble, i'm hoping you are willing to help me out:

I've compiled php 5.3 from source as CGI and put it in /usr/local/bin/php53, so the php executable is /usr/local/bin/php53/bin/php-cgi. I know CGI is slow, but i'm satisfied as long as it works.

Now i'm trying to get apache to use it.

So far, i've got this in "Customize HTTPD configurations" for the domain:
Code:
        RemoveHandler .php
                
        <FilesMatch \.php$>
             SetHandler cgi-handler
             AddHandler cgi-handler .php
        </FilesMatch>

        Action cgi-handler /usr/local/bin/php53/bin/php-cgi

	<Directory /home/client/domains/domain.com/public_html>
                
		php_admin_flag engine ON
		php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f [email protected]'
		php_admin_value mail.log /home/client/.php/php-mail.log
		php_admin_value open_basedir /home/client/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php53/lib/php/:/usr/local/php56/lib/php/:/usr/local/bin/php53
                php_admin_value disable_functions exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,mail,pear::mail,imap_mail
                php_admin_value smtp_port 99                
	</Directory>
        <Directory /home/client/domains/domain.com/public_html/administrator/cache>
             Order Deny,Allow
             Deny from All
        </Directory>
        <Directory /home/client/domains/domain.com/public_html/cache>
             Order Deny,Allow
             Deny from All
         </Directory>
        <Directory /usr/local/bin/php53>
                Order allow,deny
                Allow from all
        </Directory>

Now this configuration gives me no errors, but a 404 error on all PHP files instead. When i put a .txt file in the document root, it serves up just fine. No httpd errors logged. If i remove all lines before <Directory /home/client/domains/domain.com/public_html>, it all serves up just fine, but using the default php 5.6. Changing the owner/group of the PHP files and the document root itself to either the owner (client) or apache doesn't help.

Of course, tried several other configurations, but i've got a feeling i'm getting close with this one.
 
Back
Top