Apache
TODO Apache
- 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).
- 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
- change home directory in
 /etc/passwd 
- 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.
- copy(/move)
 /etc/{init.d,conf.d}/apache2 
to apache 
without suffix 2 - edit
 /etc/conf.d 
and set the variable CONFIGFILE 
to the appropriate new value - edit pathes in the copied config files to fit the new location
- change DOCUMEMT_ROOT in
 default_vhost.include 
- change <Directory> directives in
 00_default_ssl_vhost.conf 
, 00_default_vhost.conf 
and default_vhost.include 
- change all Include pathes
- change the MIMEMagicFile in
 00_mod_mime.conf 
Caveats:
- if a module was added/removed the
 modules.d 
folder have to be updated manual - after an update some steps to remove created files and folders have to be done
- there is still
 APACHE2_MODULES 
- eselect-php contains use flag and module apache2
- 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 - if apache was rebuild to add new modules the related config files have to be moved manually
Changes to openrc
- In
 /etc/conf.d/apache 
remove any 2's from all ${APACHE2} 
 ${APACHE2_OPTS} 
- do the same with
 /etc/init.d/apache 
and addional:- set
 PIDFILE=“${PIDFILE:-/var/run/apache.pid}” 
(optional set it in conf.d/apache 
) - in the stop function set
 pgrep -P ${PID} apache 
- Optional: do (move) all settings from the start script to config file
- change the option PidFile in
 modules.d/00_mpm.conf 
to: PidFile /run/apache.pid 
Important! (see 2b) - 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.