Can't get multiple PHP versions to work

burnacid

Verified User
Joined
Jan 10, 2016
Messages
10
I've tried alot of things. Found alot of old topics about it. But I can't get a secondary php version to work for a user

This is what my custombuild options.conf is set to:
Code:
#PHP Settings
php1_release=5.4
php1_mode=suphp
php2_release=5.5
php2_mode=mod_php

When I view the domain options for a user I'll see this where I switched 5.5 to the first PHP and 5.4 to second:

https://picasaweb.google.com/lh/photo/f-uoeb25udCZF9K6pJdFFSBC8B7hdJgReXKsxucZU_I

Then I've rebuild httpd configs and rebuild all configs. Restarted httpd multiple times but nothing.
When I load phpinfo() I get PHP Version 5.4.45

Can anyone help me out?
 
Hello,

Do you use custom or original templates for virtual hosts?

Code:
ls -la /usr/local/directadmin/data/templates/custom

How does a virtual host of a domain look like? Will you post it here? I could check your server if you want.
 
There is nothing in that folder

Code:
[root@srv01 admin]# ls -la /usr/local/directadmin/data/templates/custom
total 4
drwx--x--x. 2 diradmin diradmin    6 Oct 11  2014 .
drwx--x--x. 8 diradmin diradmin 4096 Jan 10 12:37 ..

This is a virtual host tag of one of the domains. without ip's and domainnames

Code:
<VirtualHost IP:80 >
	<Directory /home/user/domains/domain.com/public_html>
		<Limit GET POST PUT DELETE HEAD OPTIONS PATCH>
			Order allow,deny
			Allow from all
		</Limit>
	</Directory>
	ServerName www.domain.com
	ServerAlias www.domain.com domain.com  domain.nl www.domain.nl
	ServerAdmin [email protected]
	DocumentRoot /home/user/domains/domain.com/public_html
	ScriptAlias /cgi-bin/ /home/user/domains/domain.com/public_html/cgi-bin/
	UseCanonicalName OFF
	<IfModule !mod_ruid2.c>
		SuexecUserGroup user user
	</IfModule>
	CustomLog /var/log/httpd/domains/domain.com.bytes bytes
	CustomLog /var/log/httpd/domains/domain.com.log combined
	ErrorLog /var/log/httpd/domains/domain.com.error.log
	<Directory /home/user/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/user/.php/php-mail.log
		php_admin_value open_basedir /home/user/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php55/lib/php/:/usr/local/php54/lib/php/
		<FilesMatch "\.php$">
			AddHandler application/x-httpd-php .php
		</FilesMatch>
		suPHP_Engine ON
		suPHP_UserGroup user user
		<FilesMatch \.php54$>
			AddHandler x-httpd-php54 .php54
		</FilesMatch>
	</Directory>
</VirtualHost>
 
Code:
<VirtualHost IP:80 >
	<Directory /home/user/domains/domain.com/public_html>
		<Limit GET POST PUT DELETE HEAD OPTIONS PATCH>
			Order allow,deny
			Allow from all
		</Limit>
	</Directory>
	ServerName www.domain.com
	ServerAlias www.domain.com domain.com  domain.nl www.domain.nl
	ServerAdmin [email protected]
	DocumentRoot /home/user/domains/domain.com/public_html
	ScriptAlias /cgi-bin/ /home/user/domains/domain.com/public_html/cgi-bin/
	UseCanonicalName OFF
	<IfModule !mod_ruid2.c>
		SuexecUserGroup user user
	</IfModule>
	CustomLog /var/log/httpd/domains/domain.com.bytes bytes
	CustomLog /var/log/httpd/domains/domain.com.log combined
	ErrorLog /var/log/httpd/domains/domain.com.error.log
	<Directory /home/user/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/user/.php/php-mail.log
		php_admin_value open_basedir /home/user/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php55/lib/php/:/usr/local/php54/lib/php/
		<FilesMatch "\.php$">
			AddHandler application/x-httpd-php .php
		</FilesMatch>
		suPHP_Engine ON
		suPHP_UserGroup user user
		<FilesMatch \.php54$>
			AddHandler x-httpd-php54 .php54
		</FilesMatch>
	</Directory>
</VirtualHost>
 
SuPHP handlers are as the following:

suPHP_AddHandler x-httpd-php52
suPHP_AddHandler x-httpd-php53
suPHP_AddHandler x-httpd-php54
suPHP_AddHandler x-httpd-php55
suPHP_AddHandler x-httpd-php56

The handler application/x-httpd-php seems to be mod_php. So from here the things look fine.

What do you see with :

Code:
tail /usr/local/suphp/etc/suphp.conf
?
Code:
cat /etc/httpd/conf/extra/httpd-suphp.conf
?



suPHP usually is enabled the following way:

Code:
<Location />
    suPHP_Engine on
...

Once specified within <Location />... </Location> a directive can not be re-defined in other contexts. So that might be the core.

To verify it try to change /usr/local/suphp/etc/suphp.conf the following way:

change:

Code:
<Location />
    suPHP_Engine on

to

Code:
<Location />
    #suPHP_Engine on

and restart apache, and see what PHP version is used now. Make sure and check that suPHP is also working where it's enabled.

If does not help, then to make the things to work you probably need to use the both PHP versions as suPHP, or get rid of suPHP in favor of fastcgi or php-fpm.
 
/usr/local/suphp/etc/suphp.conf

Code:
;Minimum GID
min_gid=100

[handlers]
;Handler for php-scripts
x-httpd-php54="php:/usr/local/php54/bin/php-cgi54"

;Handler for CGI-scripts
x-suphp-cgi="execute:!self"
[root@srv01 admin]# cat tail /usr/local/suphp/etc/suphp.conf
cat: tail: No such file or directory
[global]
;Path to logfile
logfile=/var/log/suphp.log

;Loglevel
loglevel=warn

;User Apache is running as
webserver_user=apache

;Path all scripts have to be in
docroot=/

; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false

;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=false

;Send minor error messages to browser
errors_to_browser=true

;PATH environment variable
env_path="/bin:/usr/bin"

;Umask to set, specify in octal notation
umask=0022

;Minimum UID
min_uid=100

;Minimum GID
min_gid=100

[handlers]
;Handler for php-scripts
x-httpd-php54="php:/usr/local/php54/bin/php-cgi54"

;Handler for CGI-scripts
x-suphp-cgi="execute:!self"

/etc/httpd/conf/extra/httpd-suphp.conf

Code:
<IfModule mod_suphp.c>
<FilesMatch "\.(inc|php|php3|php4|php44|php5|php52|php53|php54|php55|php56|php70|php6|phtml|phps)$">
AddHandler x-httpd-php54 .inc .php .php3 .php4 .php5 .php54 .phtml
</FilesMatch>
<Location />
suPHP_Engine on
suPHP_ConfigPath /usr/local/php54/lib/
suPHP_AddHandler x-httpd-php54
</Location>
</IfModule>

Change the httpd-suphp.conf and commented the enabled line. Restarted httpd but that didn't change it.
Should I rebuild custombuild? What is advised to use in the options.conf. Current PHP settings are

Code:
#PHP Settings
php1_release=5.4
php1_mode=suphp
php2_release=5.5
php2_mode=mod_php
opcache=no
htscanner=no
php_ini=no
php_timezone=Europe/Amsterdam
php_ini_type=production
ioncube=yes
zend=yes
suhosin=no
x_mail_header=yes
 
What is the recommended options.conf for this?
I've tried what you said but it didn't fix it

(posted days ago but it needs to be moderated)
 
If does not help, then to make the things to work you probably need to use the both PHP versions as suPHP, or get rid of suPHP in favor of fastcgi or php-fpm.
 
How I can put a SECONDARY PHP in same domain in DIRECT ADMIN ( MOODLE)

Hello boys, i RESOLVED the problem. I suffered until I succeeded, but I succeeded.

I have big work to have two phps running in same domain. An 5.3 and a new 7.0 of MOODLE.

I have installed a moodle 5 and needed a moodle 7

I discovered an article teaching how to install 2 phps in directadmin, so far it was easy. In the control panel I put first php5.3 and second php 7.0

In all website have the same lesson, go to .htaccess and put:

AddHandler application/x-httpd-php70 .php

I try, try, try same times, i try too:

AddHandler application/x-httpd-php7 .php

Few people use directadmin and moodle at the same time, but it's my case, that's what caters me.

But I needed to have an old directory (moodle) and the new one (ava) each with a running version. And the internal DIRECTADMIN option is either one or the other. Then I would have to rename 9000 internal .php files from google to .php70, and even then knowing that it would not work, because moodle uses the "REQUIRE" command.

But what to do?

<FilesMatch "\.(inc|php|phtml|phps|php70)$">
AddHandler "proxy:unix:/usr/local/php70/sockets/DIRECTADMINUSER.sock|fcgi://localhost" .inc .php .phtml .php70
</FilesMatch>

I locate via shell the file:
/usr/local/directadmin/data/users/DIRECTADMINUSER/httpd.conf

Look the file inside: <Virtualhost>

....
CustomLog /var/log/httpd/domains/mywebsiteexample.com.log combined
ErrorLog /var/log/httpd/domains/mywebsiteexample.error.logrlo.sock|fcgi://localhost" .inc .php .phtml .ph
p56 <Directory /home/carlo/domains/mywebsiteexample.com/public_html>
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
AddHandler "proxy:unix:/usr/local/php56/sockets/DIRECTADMINUSER.sock|fcgi://localhost" .inc .php .phtml .ph
p56
</FilesMatch>
<Virtual <FilesMatch "\.(inc|php|phtml|phps|php70)$">
AddHandler "proxy:unix:/usr/local/php70/sockets/DIRECTADMINUSER.sock|fcgi://localhost" .php70
</FilesMatch>
</Directory>
</VirtualHost>

i take the text inside the <Directory> </Directory> and put its in my .htaccess, like this:

FINALY, my .htaccess file:

<FilesMatch "\.(inc|php|phtml|phps|php70)$">
AddHandler "proxy:unix:/usr/local/php70/sockets/DIRECTADMINUSER.sock|fcgi://localhost" .inc .php .phtml .php70
</FilesMatch>

Good Luck.

I'm staying here. God bless you all. A big hug!!!
Regards,

Daniel Fernando Ribeiro César - www.danielcesar.adv.br
 
Back
Top