DirectAdmin: Web control panel

Switch Apache to worker MPM

by ross at 07:23:15 on October 28, 2011

You might want to read original article on difference between prefork and worker MPM (skip section on configuration).

Rebuild DirectAdmin's Apache with worker MPM (be prepared to web sites not functiong for some time since build script will restart Apache before php is rebuilt):

# cd /usr/local/directadmin/custombuild
# ./build clean
# ./build update
# mkdir -p custom/ap2
# cp -fp configure/ap2/configure.apache custom/ap2/

Edit custom/ap2/configure.apache, note the line before the last one:

#!/bin/sh
"./configure" \
        "--prefix=/etc/httpd" \
        "--exec-prefix=/etc/httpd" \
        "--bindir=/usr/bin" \
        "--sbindir=/usr/sbin" \
        "--sysconfdir=/etc/httpd/conf" \
        "--enable-so" \
        "--enable-dav" \
        "--enable-dav-fs" \
        "--enable-dav-lock" \
        "--enable-suexec" \
        "--enable-deflate" \
        "--enable-unique-id" \
        "--with-suexec-caller=apache" \
        "--with-suexec-docroot=/" \
        "--with-suexec-gidmin=100" \
        "--with-suexec-logfile=/var/log/httpd/suexec_log" \
        "--with-suexec-uidmin=100" \
        "--with-suexec-userdir=public_html" \
        "--with-suexec-bin=/usr/sbin/suexec" \
        "--with-included-apr" \
        "--with-pcre=/usr/local" \
        "--includedir=/usr/include/apache" \
        "--libexecdir=/usr/lib/apache" \
        "--datadir=/var/www" \
        "--localstatedir=/var" \
        "--enable-logio" \
        "--enable-ssl" \
        "--enable-rewrite" \
        "--enable-proxy" \
        "--enable-expires" \
        "--with-ssl=/usr" \
        "--with-mpm=worker" \
        "--enable-headers"

Now rebuild Apache and PHP:

# cd /usr/local/directadmin/custombuild
# ./build apache
# ./build php n

You have to reinstall the extensions you might have added (eAccelerator, pecl-memcache, etc). Restart httpd from DirectAdmin webinterface.

Remeber that your extensions are now compiled thread-safe. memcache.so, for example, is installed in /extensions/no-debug-zts-<API>/ directory, not -non-zts-. Update as neccesary.

I have the following Apache configuration with worker MPM (edited both httpd-mpm.conf and httpd-mpm.conf_2.0 in /etc/httpd/conf/extra, look for "IfModule *worker*").

    StartServers          1
    ServerLimit           4
    MaxClients          256
    MinSpareThreads      32
    MaxSpareThreads      64
    ThreadsPerChild      64
    MaxRequestsPerChild   0

 

Comments