Два шага, 1 собрать PHP с исходников(другая тема) суть ее в том что бы в отедльных папках были отдельные версии PHP в инете куча статей, может и у меня дойдут руки.
Второй шаг 3 файла создать и перезапустить ispmanager
killall ispmgr |
По пути /usr/local/ispmgr/etc
создаем файл ispmgr_mod_phpversion.xml с содержимым
<?xml version="1.0" encoding="UTF-8"?> <mgrdata> <handler name="phpversion.pl" type="cgi"> <func>phpversion</func> <func>phpversion.edit</func> <func>phpversion.delete</func> <func>userphpversion</func> <func>userphpversion.enable</func> </handler> <metadata name="phpversion" type="list" key="item"> <toolbar> <toolbtn func="phpversion.edit" type="new" img="t-new" name="new"/> <toolbtn func="phpversion.edit" type="edit" img="t-edit" name="edit" default="yes"/> <toolbtn func="phpversion.delete" type="group" img="t-delete" name="delete"/> </toolbar> <coldata> <col sort="alpha" sorted="yes" name="item" type="data"/> <col sort="alpha" name="path" type="data"/> </coldata> </metadata> <metadata name="phpversion.edit" type="form"> <form> <field name="item"> <input type="text" name="item" /> </field> <field name="path"> <input type="text" name="path" /> </field> </form> </metadata> <metadata name="userphpversion" type="list" key="item"> <toolbar> <toolbtn func="userphpversion.enable" type="edit" img="t-on" name="enable" default="yes"/> </toolbar> <coldata> <col sort="alpha" sorted="yes" name="item" type="data"/> <col name="props" sort="prop"> <prop name="active" onimg="t-on" defimg="t-off"/> </col> </coldata> </metadata> <mainmenu level="7"> <node name="tool"> <node name="phpversion"/> </node> </mainmenu> <mainmenu level="5"> <node name="tool"> <node name="userphpversion"/> </node> </mainmenu> <lang name="en"> <messages name="desktop"> <msg name="menu_phpversion">PHP versions</msg> <msg name="menu_userphpversion">PHP version</msg> </messages> <messages name="phpversion"> <msg name="title">PHP versions</msg> <msg name="item">Availible versions</msg> <msg name="path">Path to binary</msg> <msg name="msg_phpversion_delete">Delete version</msg> <msg name="hint_new">Add version</msg> <msg name="hint_edit">Edit version</msg> <msg name="hint_delete">Delete version</msg> </messages> <messages name="phpversion.edit"> <msg name="title">Edit version</msg> <msg name="title_new">New version</msg> <msg name="item">Version value</msg> <msg name="path">Path to binary file</msg> <msg name="hint_item">Version value</msg> <msg name="hint_path">Path to php-cgi (e.g. /usr/bin/php-cgi)</msg> </messages> <messages name="userphpversion"> <msg name="title">PHP version in use</msg> <msg name="item">Availible versions</msg> <msg name="hint_enable">Choose version</msg> </messages> </lang> <lang name="ru"> <messages name="desktop"> <msg name="menu_phpversion">Версии PHP</msg> <msg name="menu_userphpversion">Версия PHP</msg> </messages> <messages name="phpversion"> <msg name="title">Версии PHP</msg> <msg name="item">Доступные версии</msg> <msg name="msg_phpversion_delete">Удалить версию</msg> <msg name="hint_new">Добавить версию</msg> <msg name="hint_edit">Править версию</msg> <msg name="hint_delete">Удалить версию</msg> </messages> <messages name="userphpversion"> <msg name="title">Используемая версия PHP</msg> <msg name="item">Доступные версии</msg> <msg name="hint_enable">Включить версию</msg> </messages> <messages name="phpversion.edit"> <msg name="title">Править версию</msg> <msg name="title_new">Новая версия</msg> <msg name="item">Значение версии</msg> <msg name="path">Путь до исполняемого файла</msg> <msg name="hint_item">Значение версии (5.1.6, 5.2.10) </msg> <msg name="hint_path">Путь до бинарника (например, /usr/bin/php-cgi)</msg> </messages> </lang> </mgrdata> |
По пути /usr/local/ispmgr/addon
создаем два файла, первый phpversion(в конце пустая строка обязательная в редакторе не отображается)
5.4 /usr/bin/php-cgi 5.5 /usr/local/share/phpfarm/inst/php-5.5.32/bin/php-cgi 5.6.21 /usr/local/share/phpfarm/inst/php-5.6.21/bin/php-cgi 7.0 /usr/local/share/phpfarm/inst/php-7.0.6/bin/php-cgi |
второй файл по пути /usr/local/ispmgr/addon
phpversion.pl
#!/usr/bin/perl BEGIN { push @INC, '/usr/local/ispmgr/lib/perl' } use Mgr; use CGI qw/:standard/; use strict; use warnings; my $Q = new CGI; my $func = $Q->param( "func" ); my $conf = '/usr/local/ispmgr/addon/phpversion'; print "<doc>"; my $user = $ENV{REMOTE_USER}; if (!defined $user) { print "<error>Authentication failed!</error>"; print "</doc>"; exit 0; } if( $func eq 'phpversion' ){ &List; } elsif( $func eq "phpversion.delete" ){ &Delete; } elsif( $func eq "phpversion.edit" ){ if( $Q->param( "sok" ) ){ if( $Q->param( "elid" ) ){ &Set; } else{ &New; } print "<ok/>"; } else{ &Get; } } elsif ($func eq 'userphpversion') { &UserList; } elsif ($func eq 'userphpversion.enable') { &UserSet; } print "</doc>"; exit 0; sub List { if( open( IN, $conf ) ){ while( <IN> ){ chomp; my @t = split ' ', $_; print "<elem><item>" . $t[0] . "</item><path>" . $t[1] ."</path></elem>"; } close( IN ); } } sub UserList { my $wrapper_path = "/var/www/$user/data/php-bin/php"; if ( open( WRAPPER, $wrapper_path ) ) { my $wrapper = <WRAPPER>; chomp $wrapper; if( open( IN, $conf ) ) { while( <IN> ){ chomp; my @t = split ' ', $_; print "<elem><item>" . $t[0] . "</item>"; print "<active />" if ( $wrapper eq "#!" . $t[1] ); print "</elem>"; } close( IN ); } close( WRAPPER ); } } #sub Get { # my $elid = $Q->param( "elid" ); # print "<elid>$elid</elid><item>$elid</item>" if( $elid ); #} sub Get { my $elid = $Q->param( "elid" ); my $ok = 0; if( open( IN, $conf ) ) { for( <IN> ) { chomp; my @t = split ' ', $_; if( $t[0] eq $elid ) { print '<elid>' . $t[0] . '</elid><item>' . $t[0] . '</item><path>' . $t[1] .'</path>' ; } $ok = 1; } close( IN ); } if( !$ok ) { print "<error>Item not found</error>"; } } sub Set { my $elid = $Q->param( "elid" ); my $item = $Q->param( "item" ); my $path = $Q->param( "path" ); my $ok = 0; if( open( IN, $conf ) ){ if( open( OUT, ">$conf.new" ) ){ for( <IN> ){ chomp; my @t = split ' ', $_; if( $t[0] eq $elid ){ print OUT "$item $path\n"; $ok = 1; } else { print OUT $t[0] . ' ' . $t[1] . "\n"; } } close( OUT ); } close( IN ); } if( $ok ){ rename( "$conf.new", $conf ); print "<ok/>"; } else { print "<error>Item hasn`t been updated</error>"; } } sub UserSet { my $wrapper_path = "/var/www/$user/data/php-bin/php"; my $php_ini = "/var/www/$user/data/php-bin/php.ini"; unless ( -e $php_ini ) {; print "<error>$php_ini not found</error>"; return; }; my ($login, $pass, $uid, $gid) = getpwnam($user) or print "<error>$user not in passwd file</error>"; chown $uid, $gid, $php_ini or print '<error>you are not a superuser</error>'; chmod 0644, $php_ini or print '<error>you are not a superuser</error>'; my $elid = $Q->param( "elid" ); my $item = $Q->param( "item" ); if( open( IN, $conf ) ){ if( open( OUT, ">", $wrapper_path ) ){ for( <IN> ){ chomp; my @t = split ' ', $_; if( $t[0] eq $elid ){ print OUT '#!' . $t[1] . "\n"; } } close( OUT ); } close( IN ); } my $check_for_timezone = `cat $php_ini | grep date.timezone`; my $is_php_53 = `cat $wrapper_path | grep 5.4`; # need for bitrix install, only for 5.4 if ( $is_php_53 && !$check_for_timezone && open( OUT, ">>", $php_ini ) ) { print OUT "date.timezone='Europe/Moscow'\n"; close( OUT ); } my $check_for_maillog = `cat $php_ini | grep mail.log`; if ( $is_php_53 && !$check_for_maillog && open( OUT, ">>", $php_ini ) ) { print OUT "mail.log = \"/var/www/$user/data/mail.log\"\n"; print OUT "mail.add_x_header = On\n"; close( OUT ); } print "<ok>restart</ok>"; } sub New { my $elid = $Q->param( "elid" ); my $item = $Q->param( "item" ); my $path = $Q->param( "path" ); if( open( ADD, ">>$conf" ) ){ print ADD "$item $path\n"; close( ADD ); print "<ok/>"; } else { print "<error>Item hasn`t been added</error>"; } } sub Delete { my $elid = $Q->param( "elid" ); if( open( IN, "$conf" ) ){ if( open( OUT, ">$conf.new" ) ){ for( <IN> ){ chomp; my @t = split ' ', $_; print OUT $t[0] . ' ' . $t[1] . "\n" if( $t[0] ne $elid ); } close( OUT ); } close( IN ); } rename( "$conf.new", "$conf" ); print "<ok/>"; } |