User Tools

Site Tools


Home
Optimizations


Apache

TODO Apache

  1. is installed with a suffix 2 (apache2, apache2ctl) this is first not required and second inconsistent done (the man pages are still called apache and apachectl).
  2. is not part of the operating system, thus it have to be separated from  /var  (the  www  folder) at least. More over perhaps from  /etc  and  /var/log .

Additional I'm not convinced that the portage category  www-apps  makes sense.

Steps

  1. change home directory in  /etc/passwd 
  2. create the new home directory (e.g.  /home/srvc/apache ) with subfolders ( {etc,log,www} )
    • After a fresh installation move the  /var/www  and  /etc/apache2  folders into the new home folder.
  3. copy(/move)  /etc/{init.d,conf.d}/apache2  to  apache  without suffix 2
  4. edit  /etc/conf.d  and set the variable  CONFIGFILE  to the appropriate new value
  5. edit pathes in the copied config files to fit the new location FIXME
    1. change DOCUMEMT_ROOT in  default_vhost.include 
    2. change <Directory> directives in  00_default_ssl_vhost.conf ,  00_default_vhost.conf  and  default_vhost.include 
    3. change all Include pathes
  6. change the MIMEMagicFile in  00_mod_mime.conf 

Caveats:

  1. if a module was added/removed the  modules.d  folder have to be updated manual
  2. after an update some steps to remove created files and folders have to be done
  3. there is still  APACHE2_MODULES 
  4. eselect-php contains use flag and module apache2
  5. apache is build with  -D SERVER_CONFIG_FILE=“/etc/apache2/httpd.conf”  and  -D AP_TYPES_CONFIG_FILE=“/etc/apache2/mime.types”  - have to be overwritten via command line
  6. if apache was rebuild to add new modules the related config files have to be moved manually

Changes to openrc

  1. In  /etc/conf.d/apache  remove any 2's from all  ${APACHE2}   ${APACHE2_OPTS} 
  2. do the same with  /etc/init.d/apache  and addional:
    1. set  PIDFILE=“${PIDFILE:-/var/run/apache.pid}”  (optional set it in  conf.d/apache )
    2. in the stop function set  pgrep -P ${PID} apache 
    3. Optional: do (move) all settings from the start script to config file
  3. change the option PidFile in  modules.d/00_mpm.conf  to:  PidFile /run/apache.pid  Important! (see 2b)
  4. move binary  apache2  to  /usr/sbin/apache 

The  apache2ctl  is Gentoo specific and doesn't look like a subject of change often. Below an adjusted version renamed to  apachectl :

#!/bin/sh
 
APACHE="/usr/sbin/apache"
APACHE_OPTS=""
APACHE_RC_CONF="/etc/conf.d/apache"
# List of init script verbs that should be passed forward
RC_VERBS="start stop restart checkconfd configtest modules virtualhosts configdump fullstatus graceful gracefulstop reload"
 
load_rc_config() {
        [ -f "${APACHE_RC_CONF}" ] || return 1
        eval "export $(grep '^[[:space:]]*APACHE_OPTS' ${APACHE_RC_CONF})"
        eval $(grep '^[[:space:]]*SERVERROOT' ${APACHE_RC_CONF})
        eval $(grep '^[[:space:]]*CONFIGFILE' ${APACHE_RC_CONF})
        export SERVERROOT="${SERVERROOT:-/usr/lib64/apache2}"
        export CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"   # edit the last part (optional)
}
 
# If first parameter is a verb defined in $RC_VERBS, pass the command to init script.
# In other cases, compile command line and run the command on apache binary.
if echo "${RC_VERBS}" | grep -q "${1}" ; then
        exec /etc/init.d/apache "${@}"
else
        load_rc_config || exit 1
        ${APACHE} ${APACHE_OPTS} -d ${SERVERROOT} -f ${CONFIGFILE} "${@}"
fi

(This was until gentoo-apache-2.4.38)

Issue: After using  gracefulstop  the open-rc status shows crashed ( /etc/init.d/apache status ). But apache is NOT really crashed, as a  graceful  (to start again) works fine and a  zap  isn't required.