MRatWork Forum by Mustafa Ramadhan

Sawo Project - Kloxo-MR Discussions => Kloxo-MR Development => Topic started by: LotsOfQ on 2015-04-15, 06:21:31

Title: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 06:21:31
Is this feature "Multiple PHP Enable" working yet? And if so then how do we use it?
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 06:27:03
Still not work. But, you can use various php in website via 'secondary php'.
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 08:21:42
Thank you for your answer.

How does this work? Do you have any post on this that I can read up on?
Quote
But, you can use various php in website via 'secondary php'.
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 09:04:34
1. goto to 'admin > webserver configure'
2. Install all php in 'multiple php install' until show in 'Multiple PHP Already Installed'
3. Use one 'phpXYm' in 'php used' as 'base php' in 'webserver configure'
4. select 'php-fpm_event' for 'php type' also enable 'Enable PHP 5.2 (use Php52s) As Secondary PHP' (it's wrong description because possible not php 5.2 only)
5. go to 'admin > switch program' and select apache or proxy (like nginxproxy)
6. Restart webserver with 'sh /script/restart-web -y' from ssh or 'admin > command center'
7. Add:
Code: [Select]
<Ifmodule !mod_php5.c>
    AddHandler x-httpd-php52 .php
    #AddHandler x-httpd-php .php
</Ifmodule>
in top line of /home/<user>/<domain>/.htaccess (change php52 to php53 if want to use php 5.3)

8. Testing php with create phpinfo.php with content '<?php phpinfo(); ?>'

Note:
- You can see this feature with access to:
Code: [Select]
http://xl2.mratwork.com/php52/
http://xl2.mratwork.com/php53/
http://xl2.mratwork.com/php54/
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 10:52:50
Wow... this is perfect if I understand it correctly. Awesome. Just what I needed but never though it was possible. I will test now.

Oh... is it possible to not just apply this to domain but also directory. ex. /home/user/domain/thisdir/.htaccess?
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 11:17:15
Wow... this is perfect if I understand it correctly. Awesome. Just what I needed but never though it was possible. I will test now.

Oh... is it possible to not just apply this to domain but also directory. ex. /home/user/domain/thisdir/.htaccess?

Yes, possible different php version per-directory. Did you see http://xl2.mratwork.com/
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 11:22:56
Yeah, I saw it. That's exactly what I want. I am trying it on my end but not working. Everytime I open a page it start to download it instead. Any idea?

By they way, this is fixed when I switch to php54. http://forum.mratwork.com/kloxo-mr-technical-helps/headers-and-client-library-minor-version-mismatch-headers50173-library50312/
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 12:02:11
Ok, so it works. The reason why it didn't the directory already have an .htaccess file with this on it.

Quote
<FilesMatch "\.inc$">
        #Order allow,deny
        #Deny from all
</FilesMatch>

So I did this and it didn't work.
Quote
<Ifmodule !mod_php5.c>
    AddHandler x-httpd-php52 .php
    #AddHandler x-httpd-php .php
</Ifmodule>

<FilesMatch "\.inc$">
        #Order allow,deny
        #Deny from all
</FilesMatch>

But this alone work.

Quote
<Ifmodule !mod_php5.c>
    AddHandler x-httpd-php52 .php
    #AddHandler x-httpd-php .php
</Ifmodule>

How do I have it together?
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 12:09:57
Let say:

- directory '/home/admin/xl2.mratwork.com/php52' with content 'AddHandler x-httpd-php52 .php' inside '/home/admin/xl2.mratwork.com/php52/.htaccess'

- directory '/home/admin/xl2.mratwork.com/php53' with content 'AddHandler x-httpd-php53 .php' inside '/home/admin/xl2.mratwork.com/php53/.htaccess'
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 12:21:47
I think you missed my last post. I am wondering what do I do if I have already have existing .htaccess with code inside.
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 12:36:32
Sorry I was wrong. When I have change php52 then it work fine. But when I change it to php53 that's when it download the page or file.
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 12:52:50
Inform here 'dir -l /opt; php53m-cli -v;cat /etc/suphp.conf; cat /etc/httpd/conf.d/suphp52.conf'
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 13:01:28
Quote
total 28
drwxr-xr-x 20 root root 4096 Apr 12 04:53 configs
drwxr-xr-x  6 root root 4096 Apr 15 10:50 php52m
drwxr-xr-x  6 root root 4096 Apr 14 13:05 php53m
drwxr-xr-x  6 root root 4096 Apr 14 13:05 php54m
drwxr-xr-x  6 root root 4096 Apr 12 04:50 php54s
drwxr-xr-x  6 root root 4096 Apr 15 10:51 php55m
drwxr-xr-x  6 root root 4096 Apr 15 10:52 php56m
PHP 5.3.29 (cli) (built: Aug 14 2014 11:50:05)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
[global]
logfile=/var/log/httpd/suphp_log
loglevel=info
webserver_user=apache
docroot=/
env_path=/bin:/usr/bin
umask=0022
min_uid=48
min_gid=48

; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
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=false

[handlers]
;Handler for php-scripts
x-httpd-php="php:/usr/bin/php-cgi"
x-httpd-php52="php:/opt/php52m/custom/php-cgi.sh"
x-httpd-php53="php:/opt/php53m/custom/php-cgi.sh"
x-httpd-php54="php:/opt/php54m/custom/php-cgi.sh"
x-httpd-php55="php:/opt/php55m/custom/php-cgi.sh"

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

;;; MR -- for using php52 just enough add 'AddHandler x-httpd-php52 .php' on .htaccess.
;;; The same way for php53 until php55
;;; it's make possible running 'multiple php' on server!
### MR -- read /usr/local/lxlabs/kloxo/file/apache/conf.d/suphp.conf.original for full description ###

LoadModule suphp_module modules/mod_suphp.so

suPHP_Engine On

#AddHandler x-httpd-php .php
#AddHandler x-httpd-php .php .php4 .php3 .phtml

suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php52

DirectoryIndex index.php
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-15, 13:18:59
In /etc/httpd/conf.d/suphp52.conf, add:
Code: [Select]
suPHP_AddHandler x-httpd-php53
suPHP_AddHandler x-httpd-php54
suPHP_AddHandler x-httpd-php55

under:
Code: [Select]
suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php52
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-15, 13:34:47
Work perfectly!!! Thank you so much. You're best!
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-16, 07:36:15
Just curious, is it possible to turn on register_globals with this?

Like:

directory1 php52 register_globals = on
directory2 php55 register_globals = on
directory3 php54 register_globals = off

Can we do that with htaccess?
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-16, 07:45:30
Possible yes but need customize with using 'customize rule'.
Title: Re: Multiple PHP Enable
Post by: LotsOfQ on 2015-04-16, 07:48:54
so nothing simply like adding this to htaccess?
<IfModule mod_php5.c>
  php_value register_globals 1
</IfModule>
Title: Re: Multiple PHP Enable
Post by: MRatWork on 2015-04-16, 08:00:30
so nothing simply like adding this to htaccess?
<IfModule mod_php5.c>
  php_value register_globals 1
</IfModule>
It's only work for prefork like ruid2 and itk. Need modified php.ini directly with follow 'customize rule'.