up
ГлавнаяБлогБезопасностьЖелезоПрограммированиеАдминистрирование
LinuxDebianRAMBenchmarkHTMLBashFreeBSDHDDPHPCPUPerlMySQLCentOSSSD

Популярные статьи
Категория “Администрирование

Как прикрутить MPM-ITK к WHM/cPanel

1. Собираем апач с MPM-Prefork и php в режиме dso (mod_php) со всеми опциями и настройками, которые вы посчитаете нужными. С помощью EasyApache.

2. Сохраняем копию mod_php, так как при сборке в MPM-ITK easyapache не делает dso для php:

cp /usr/local/apache/modules/libphp5.so /root

3. Скачаем и распакуем модуль MPM-ITK для easyapache:

cd /root
wget http://docs.cpanel.net/twiki/pub/EasyApache3/CustomMods/MPMitk.tar.gz
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf MPMitk.tar.gz

4. Собираем апач только уже с MPM-ITK.

5. Копируем модуль апача, для подключения DSO при ITK:

cp /root/libphp5.so /usr/local/apache/modules/

6. Рестарт апача

/etc/init.d/httpd restart

7. Подключение dso

/usr/local/cpanel/bin/rebuild_phpconf 5 none dso enabled

8. Копируем файл /var/cpanel/templates/apache2/vhost.default в /var/cpanel/templates/apache2/vhost.local и добавляем после [% IF vhost.user != 'nobody' -%]:

AssignUserID [% vhost.user %] [% vhost.group %]
MaxClientsVHost 25

9. Создаем файлик /var/cpanel/template_compiles/var/cpanel/templates/apache2/vhost.local

 

#------------------------------------------------------------------------
# Compiled template generated by the Template Toolkit version 2.24
#------------------------------------------------------------------------

Template::Document->new({
    METADATA => {
        'modtime' => '1357597251',
        'name' => 'apache2/vhost.local',
    },
    BLOCK => sub {
        my $context = shift || die "template sub called without context\n";
        my $stash   = $context->stash;
        my $output  = '';
        my $_tt_error;

        eval { BLOCK: {
    $output .=  "\n<VirtualHost";
#line 2 "/var/cpanel/templates/apache2/vhost.local"

    # FOREACH
    do {
        my ($_tt_value, $_tt_error, $_tt_oldloop);
        my $_tt_list = $stash->get(['vhost', 0, 'ips', 0]);

        unless (UNIVERSAL::isa($_tt_list, 'Template::Iterator')) {
            $_tt_list = Template::Config->iterator($_tt_list)
                || die $Template::Config::ERROR, "\n";
        }

        ($_tt_value, $_tt_error) = $_tt_list->get_first();
        eval { $_tt_oldloop = $stash->get('loop') };
        $stash->set('loop', $_tt_list);
        eval {
    FOR1:   while (! $_tt_error) {
                $stash->{'ipblock'} = $_tt_value;
    $output .=  " ";
#line 2 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['ipblock', 0, 'ip', 0]);
    $output .=  ":";
#line 2 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['ipblock', 0, 'port', 0]);;
                ($_tt_value, $_tt_error) = $_tt_list->get_next();
            }
        };
        $stash->set('loop', $_tt_oldloop);
        die [email protected] if [email protected];
        $_tt_error = 0 if $_tt_error && $_tt_error eq Template::Constants::STATUS_DONE;
        die $_tt_error if $_tt_error;
    };

    $output .=  ">\n    ServerName ";
#line 3 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'servername', 0]);
    $output .=  "\n";
#line 10 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'serveralias_array', 0, 'size', 0])) {
#line 7 "/var/cpanel/templates/apache2/vhost.local"

    # FOREACH
    do {
        my ($_tt_value, $_tt_error, $_tt_oldloop);
        my $_tt_list = $stash->get(['vhost', 0, 'serveralias_array', 0]);

        unless (UNIVERSAL::isa($_tt_list, 'Template::Iterator')) {
            $_tt_list = Template::Config->iterator($_tt_list)
                || die $Template::Config::ERROR, "\n";
        }

        ($_tt_value, $_tt_error) = $_tt_list->get_first();
        eval { $_tt_oldloop = $stash->get('loop') };
        $stash->set('loop', $_tt_list);
        eval {
    FOR1:   while (! $_tt_error) {
                $stash->{'alias'} = $_tt_value;
    $output .=  "    ServerAlias ";
#line 6 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('alias');
    $output .=  "\n";;
                ($_tt_value, $_tt_error) = $_tt_list->get_next();
            }
        };
        $stash->set('loop', $_tt_oldloop);
        die [email protected] if [email protected];
        $_tt_error = 0 if $_tt_error && $_tt_error eq Template::Constants::STATUS_DONE;
        die $_tt_error if $_tt_error;
    };

    }
    else {
    $output .=  "    ServerAlias ";
#line 9 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'serveralias', 0]);
    $output .=  "\n";
    }

    $output .=  "    DocumentRoot ";
#line 11 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  "\n";
#line 16 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'serveradmin', 0])) {
    $output .=  "    ServerAdmin ";
#line 13 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'serveradmin', 0]);
    $output .=  "\n";
    }
    else {
    $output .=  "\n    ServerAdmin webmaster\@";
#line 15 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'servername', 0]);
    $output .=  "\n";
    }

#line 21 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'usecanonicalname', 0])) {
    $output .=  "    UseCanonicalName ";
#line 18 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'usecanonicalname', 0]);
    $output .=  "\n";
    }
    else {
    $output .=  "\n    UseCanonicalName Off\n";
    }

#line 25 "/var/cpanel/templates/apache2/vhost.local"
    if (! $stash->get(['vhost', 0, 'hascgi', 0])) {
    $output .=  "    Options -ExecCGI -Includes\n    RemoveHandler cgi-script .cgi .pl .plx .ppl .perl\n";
    }

#line 32 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get('logstyle') eq 'combined') {
#line 29 "/var/cpanel/templates/apache2/vhost.local"
    if (! $stash->get('enable_piped_logs') || ! $stash->get(['supported', 0, 'mod_log_config', 0])) {
    $output .=  "    CustomLog ";
#line 28 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('serverroot');
    $output .=  "/domlogs/";
#line 28 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'log_servername', 0]);
    $output .=  " combined";
    }

    $output .=  "\n";
    }
    else {
    $output .=  "\n    TransferLog ";
#line 31 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('serverroot');
    $output .=  "/domlogs/";
#line 31 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'log_servername', 0]);
    $output .=  "\n";
    }

#line 35 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['supported', 0, 'mod_log_config', 0]) && $stash->get(['supported', 0, 'mod_logio', 0]) && ! $stash->get('enable_piped_logs')) {
    $output .=  "    CustomLog ";
#line 34 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('serverroot');
    $output .=  "/domlogs/";
#line 34 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'log_servername', 0]);
    $output .=  "-bytes_log \"%{%s}t %I .\\n%{%s}t %O .\"\n";
    }

    $output .=  "    ## User ";
#line 36 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " # Needed for Cpanel::ApacheConf\n";
#line 40 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['supported', 0, 'mod_userdir', 0]) && $stash->get('userdirprotect_enabled') && $stash->get(['vhost', 0, 'userdirprotect', 0]) ne '-1') {
    $output .=  "    UserDir disabled\n    UserDir enabled ";
#line 39 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " ";
#line 39 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'userdirprotect', 0]);
    $output .=  "\n";
    }

#line 45 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['supported', 0, 'mod_suphp', 0])) {
    $output .=  "    <IfModule mod_suphp.c>\n        suPHP_UserGroup ";
#line 43 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " ";
#line 43 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'group', 0]);
    $output .=  "\n    </IfModule>\n";
    }

#line 62 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get('phpopenbasedirprotect_enabled') && $stash->get(['vhost', 0, 'phpopenbasedirprotect', 0]) && ($stash->get(['supported', 0, 'libphp4', 0]) || $stash->get(['supported', 0, 'libphp5', 0]))) {
    $output .=  "    <IfModule concurrent_php.c>\n        php4_admin_value open_basedir \"";
#line 48 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  ":/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp\"\n        php5_admin_value open_basedir \"";
#line 49 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  ":/usr/lib/php:/usr/local/lib/php:/tmp\"\n    </IfModule>\n    <IfModule !concurrent_php.c>\n        <IfModule mod_php4.c>\n            php_admin_value open_basedir \"";
#line 53 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  ":/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp\"\n        </IfModule>\n        <IfModule mod_php5.c>\n            php_admin_value open_basedir \"";
#line 56 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  ":/usr/lib/php:/usr/local/lib/php:/tmp\"\n        </IfModule>\n        <IfModule sapi_apache2.c>\n            php_admin_value open_basedir \"";
#line 59 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  ":/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp\"\n        </IfModule>\n    </IfModule>\n";
    }

#line 74 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'user', 0]) ne 'nobody') {
    $output .=  "  AssignUserID  ";
#line 64 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " ";
#line 64 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'group', 0]);
    $output .=  "\n  MaxClientsVHost 25\n    <IfModule !mod_disable_suexec.c>\n        <IfModule !mod_ruid2.c>\n            SuexecUserGroup ";
#line 68 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " ";
#line 68 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'group', 0]);
    $output .=  "\n        </IfModule>\n    </IfModule>\n    <IfModule mod_ruid2.c>\n        RUidGid ";
#line 72 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  " ";
#line 72 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'group', 0]);
    $output .=  "\n    </IfModule>\n";
    }

#line 79 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['supported', 0, 'mod_alias', 0])) {
#line 78 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'hascgi', 0]) && $stash->get('scriptalias') eq 1) {
    $output .=  "    ScriptAlias /cgi-bin/ ";
#line 77 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'documentroot', 0]);
    $output .=  "/cgi-bin/\n";
    }

    }

#line 80 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 0);
#line 128 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['file_test', [ 'd', '/usr/local/apache/conf/userdata/' ]])) {
#line 85 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['fglob', [ '/usr/local/apache/conf/userdata/*.conf' ]])) {
#line 83 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"/usr/local/apache/conf/userdata/*.conf\"";
    }

#line 89 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'owner', 0]) && $stash->get(['fglob', [ '/usr/local/apache/conf/userdata/*.owner-'  . $stash->get(['vhost', 0, 'owner', 0]) ]])) {
#line 87 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"/usr/local/apache/conf/userdata/*.owner-";
#line 88 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'owner', 0]);
    $output .=  "\"";
    }

#line 127 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['file_test', [ 'd', '/usr/local/apache/conf/userdata/std' ]])) {
#line 94 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['fglob', [ '/usr/local/apache/conf/userdata/std/*.conf' ]])) {
#line 92 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"/usr/local/apache/conf/userdata/std/*.conf\"";
    }

#line 98 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'owner', 0]) && $stash->get(['fglob', [ '/usr/local/apache/conf/userdata/std/*.owner-'  . $stash->get(['vhost', 0, 'owner', 0]) ]])) {
#line 96 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"/usr/local/apache/conf/userdata/std/*.owner-";
#line 97 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'owner', 0]);
    $output .=  "\"";
    }

#line 99 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('vhost_include_base', '/usr/local/apache/conf/userdata/std/2/');
#line 126 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['file_test', [ 'd', $stash->get('vhost_include_base') ]])) {
#line 104 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['fglob', [ $stash->get('vhost_include_base')  . '*.conf' ]])) {
#line 102 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"";
#line 103 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('vhost_include_base');
    $output .=  "*.conf\"";
    }

#line 108 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['vhost', 0, 'owner', 0]) && $stash->get(['fglob', [ $stash->get('vhost_include_base')  . '*.owner-'  . $stash->get(['vhost', 0, 'owner', 0]) ]])) {
#line 106 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"";
#line 107 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('vhost_include_base');
    $output .=  "*.owner-";
#line 107 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'owner', 0]);
    $output .=  "\"";
    }

#line 125 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['file_test', [ 'd', $stash->get('vhost_include_base')  . $stash->get(['vhost', 0, 'user', 0]) ]])) {
#line 113 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['fglob', [ $stash->get('vhost_include_base')  . $stash->get(['vhost', 0, 'user', 0])  . '/*.conf' ]])) {
#line 111 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"";
#line 112 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('vhost_include_base');
#line 112 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  "/*.conf\"";
    }

#line 114 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('domains_list', $stash->get(['vhost', 0, 'serveralias', 0, 'split', [ ' ' ]]));
#line 115 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['domains_list', 0, 'push', [ $stash->get(['vhost', 0, 'servername', 0]) ]]);
#line 124 "/var/cpanel/templates/apache2/vhost.local"

    # FOREACH
    do {
        my ($_tt_value, $_tt_error, $_tt_oldloop);
        my $_tt_list = $stash->get(['domains_list', 0, 'unique', 0]);

        unless (UNIVERSAL::isa($_tt_list, 'Template::Iterator')) {
            $_tt_list = Template::Config->iterator($_tt_list)
                || die $Template::Config::ERROR, "\n";
        }

        ($_tt_value, $_tt_error) = $_tt_list->get_first();
        eval { $_tt_oldloop = $stash->get('loop') };
        $stash->set('loop', $_tt_list);
        eval {
    FOR1:   while (! $_tt_error) {
                $stash->{'domain'} = $_tt_value;
#line 117 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('domain', $stash->get(['wildcard_safe', [ $stash->get('domain') ]]));
#line 123 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['file_test', [ 'd', $stash->get('vhost_include_base')  . $stash->get(['vhost', 0, 'user', 0])  . '/'  . $stash->get('domain') ]])) {
#line 122 "/var/cpanel/templates/apache2/vhost.local"
    if ($stash->get(['fglob', [ $stash->get('vhost_include_base')  . $stash->get(['vhost', 0, 'user', 0])  . '/'  . $stash->get('domain')  . '/*.conf' ]])) {
#line 120 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('added_include', 1);
    $output .=  "\n    Include \"";
#line 121 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('vhost_include_base');
#line 121 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  "/";
#line 121 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('domain');
    $output .=  "/*.conf\"";
    }

    }
    ;
                ($_tt_value, $_tt_error) = $_tt_list->get_next();
            }
        };
        $stash->set('loop', $_tt_oldloop);
        die [email protected] if [email protected];
        $_tt_error = 0 if $_tt_error && $_tt_error eq Template::Constants::STATUS_DONE;
        die $_tt_error if $_tt_error;
    };

    }

    }

    }

    }

#line 135 "/var/cpanel/templates/apache2/vhost.local"
    if (! $stash->get('added_include')) {
#line 130 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('vhost_include_base', '/usr/local/apache/conf/userdata/std/2/');
#line 131 "/var/cpanel/templates/apache2/vhost.local"
    $stash->set('domain', $stash->get(['wildcard_safe', [ $stash->get(['vhost', 0, 'servername', 0]) ]]));
    $output .=  "\n\n    # To customize this VirtualHost use an include file at the following location\n    # Include \"";
#line 134 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('vhost_include_base');
#line 134 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get(['vhost', 0, 'user', 0]);
    $output .=  "/";
#line 134 "/var/cpanel/templates/apache2/vhost.local"
    $output .=  $stash->get('domain');
    $output .=  "/*.conf\"";
    }

    $output .=  "\n\n</VirtualHost>\n";
        } };
        if ([email protected]) {
            $_tt_error = $context->catch([email protected], \$output);
            die $_tt_error unless $_tt_error->type eq 'return';
        }

        return $output;
    },
    DEFBLOCKS => {

    },
});

 

10. Запрещаем изменения вышеуказанных файлов:

chattr +i /var/cpanel/templates/apache2/vhost.local
chattr -i /var/cpanel/template_compiles/var/cpanel/templates/apache2/vhost.local

Tuesday, 19 August 2014, 23:44Прочитано 40 раз
Ссылка на страницу:

comments powered by Disqus

Чаще всего ищут

Статистика блога
Статтей: 177
Безопасность: 9
Железо: 19
Программирование: 14
Администрирование: 134