You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output from apache2ctl -S looks like a suitable candidate for conversion into JSON, this is what I have on a development server:
apache2ctl -S
VirtualHost configuration:
127.0.0.1:80 localhost (/etc/apache2/sites-enabled/localhost.conf:4)
*:80 is a NameVirtualHost
default server wsh.webarchitects.org.uk (/etc/apache2/conf-enabled/webarch.conf:113)
port 80 namevhost wsh.webarchitects.org.uk (/etc/apache2/conf-enabled/webarch.conf:113)
alias www.wsh.webarchitects.org.uk
port 80 namevhost nextcloud.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/cloud.conf:22)
alias cloud.wsh.webarchitects.org.uk
alias www.nextcloud.wsh.webarchitects.org.uk
port 80 namevhost nextcloud2.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/cloud2.conf:22)
port 80 namevhost foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:22)
alias cgi.foobar.wsh.webarchitects.org.uk
alias foo.foobar.wsh.webarchitects.org.uk
alias bar.foobar.wsh.webarchitects.org.uk
port 80 namevhost fcgi.foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:110)
port 80 namevhost php.foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:184)
port 80 namevhost mautic.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/mautic.conf:22)
port 80 namevhost moodle.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/moodle.conf:22)
port 80 namevhost phpmyadmin.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/phpmyadmin.conf:22)
port 80 namevhost stats.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/stats.conf:22)
port 80 namevhost time.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/time.conf:22)
alias www.time.wsh.webarchitects.org.uk
alias time.wsh.webarch.org.uk
alias www.time.wsh.webarch.org.uk
port 80 namevhost weblog.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/weblog.conf:22)
alias blog.wsh.webarch.org.uk
alias blog.wsh.webarchitects.org.uk
alias weblog.wsh.webarch.org.uk
port 80 namevhost wiki.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/wiki.conf:22)
alias www.mediawiki.wsh.webarchitects.org.uk
alias wiki.mediawiki.wsh.webarchitects.org.uk
*:443 is a NameVirtualHost
default server wsh.webarchitects.org.uk (/etc/apache2/conf-enabled/webarch.conf:152)
port 443 namevhost wsh.webarchitects.org.uk (/etc/apache2/conf-enabled/webarch.conf:152)
alias www.wsh.webarchitects.org.uk
port 443 namevhost nextcloud.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/cloud.conf:42)
alias cloud.wsh.webarchitects.org.uk
alias www.nextcloud.wsh.webarchitects.org.uk
port 443 namevhost nextcloud2.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/cloud2.conf:35)
port 443 namevhost foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:45)
alias cgi.foobar.wsh.webarchitects.org.uk
alias foo.foobar.wsh.webarchitects.org.uk
alias bar.foobar.wsh.webarchitects.org.uk
port 443 namevhost fcgi.foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:123)
port 443 namevhost php.foobar.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/foobar.conf:197)
port 443 namevhost mautic.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/mautic.conf:35)
port 443 namevhost moodle.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/moodle.conf:35)
port 443 namevhost phpmyadmin.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/phpmyadmin.conf:35)
port 443 namevhost stats.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/stats.conf:35)
port 443 namevhost time.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/time.conf:45)
alias www.time.wsh.webarchitects.org.uk
alias time.wsh.webarch.org.uk
alias www.time.wsh.webarch.org.uk
port 443 namevhost weblog.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/weblog.conf:45)
alias blog.wsh.webarch.org.uk
alias blog.wsh.webarchitects.org.uk
alias weblog.wsh.webarch.org.uk
port 443 namevhost wiki.wsh.webarchitects.org.uk (/etc/apache2/sites-enabled/wiki.conf:42)
alias www.mediawiki.wsh.webarchitects.org.uk
alias wiki.mediawiki.wsh.webarchitects.org.uk
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex fcgid-pipe: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
ChrootDir: "/chroots/www-data"
I guess the first thing to do would be to track down the code that generates this output, this is the content of /usr/sbin/apache2ctl on Debian:
#!/bin/sh## Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.### Apache control script designed to allow an easy command line interface# to controlling Apache. Written by Marc Slemko, 1997/08/23## Heavily modified for Debian by Stefan Fritsch 2007-2010## The exit codes returned are:# XXX this doc is no longer correct now that the interesting# XXX functions are handled by httpd# 0 - operation completed successfully# 1 - # 2 - usage error# 3 - httpd could not be started# 4 - httpd could not be stopped# 5 - httpd could not be started during a restart# 6 - httpd could not be restarted during a restart# 7 - httpd could not be restarted during a graceful restart# 8 - configuration syntax error## When multiple arguments are given, only the error from the _last_# one is reported. Run "apachectl help" for usage info#
ARGV="$@"## |||||||||||||||||||| START CONFIGURATION SECTION ||||||||||||||||||||# -------------------- --------------------## main configuration directoryiftest -z "$APACHE_CONFDIR";theniftest"${0##*apache2ctl-}"!= "$0";then
APACHE_CONFDIR="/etc/apache2-${0##*apache2ctl-}"else
APACHE_CONFDIR=/etc/apache2
fifi
SUFFIX="${APACHE_CONFDIR##/etc/apache2-}"case"$SUFFIX"in
/etc/apache2)
SUFFIX=""
;;
*)
SUFFIX="@$SUFFIX"
;;
esac
APACHE_SYSTEMD_SERVICE="apache2$SUFFIX"# the path to the environment variable filetest -z "$APACHE_ENVVARS"&& APACHE_ENVVARS="$APACHE_CONFDIR/envvars"# pick up any necessary environment variablesiftest -f $APACHE_ENVVARS;then.$APACHE_ENVVARSfiiftest"$APACHE_CONFDIR"!= /etc/apache2 ;then
APACHE_ARGUMENTS="-d $APACHE_CONFDIR$APACHE_ARGUMENTS"fi# the following APACHE_* variables should be set in /etc/apache2/envvars## the path to your httpd binary, including options if necessary
HTTPD=${APACHE_HTTPD:-/usr/sbin/apache2}## a command that outputs a formatted text version of the HTML at the# url given on the command line. Designed for lynx, however other# programs may work.
LYNX="${APACHE_LYNX:-www-browser -dump}"## the URL to your server's mod_status status page. If you do not# have one, then status and fullstatus will not work.
STATUSURL="${APACHE_STATUSURL:-http://localhost:80/server-status}"## Set this variable to a command that increases the maximum# number of file descriptors allowed per child process. This is# critical for configurations that use many file descriptors,# such as mass vhosting, or a multithreaded server.
ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-ulimit -n 8192}"# -------------------- --------------------# |||||||||||||||||||| END CONFIGURATION SECTION ||||||||||||||||||||# Set the maximum number of file descriptors allowed per child process.if [ "x$ULIMIT_MAX_FILES"!="x" ] && [ `id -u`-eq 0 ] ;thenif!$ULIMIT_MAX_FILES;thenecho Setting ulimit failed. See README.Debian for more information. >&2fifi
ERROR=0
if [ "x$ARGV"="x" ] || [ "x$ARGV"="xusage" ] || [ "x$ARGV"="xhelp" ] || [ "x$ARGV"="x--help" ];thenecho"Usage: $0 start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus|help">&2echo"$0 <apache2 args>">&2echo"$0 -h (for help on <apache2 args>)">&2exit 1
figet_status () {
if!$LYNX$STATUSURL;thenecho"'$LYNX$STATUSURL'" failed. >&2echo Maybe you need to install a package providing www-browser or you >&2echo need to adjust the APACHE_LYNX variable in /etc/apache2/envvars >&2exit 1
fi
}
mkdir_chown () {
local OWNER="$1"local DIR="$2"local STAT="$(LC_ALL=C stat -c %F:%U $DIR2> /dev/null || true)"if [ "$STAT"="" ] ;thenlocal TMPNAME=$(mktemp -d $DIR.XXXXXXXXXX)||exit 1
chmod 755 $TMPNAME||exit 1
chown $OWNER$TMPNAME||exit 1
if! mv -T $TMPNAME$DIR2> /dev/null;then
rmdir $TMPNAME# check for race with other apachectlif [ "$(LC_ALL=C stat -c %F:%U $DIR2>/dev/null)"!="directory:$OWNER" ]
thenecho Cannot create $DIR with owner $OWNER.
echo Please fix manually. Aborting.
exit 1
fifielif [ "$STAT"!="directory:$OWNER" ] ;thenecho$DIR already exists but is not a directory owned by $OWNER.
echo Please fix manually. Aborting.
exit 1
fi
}
[ !-d${APACHE_RUN_DIR:-/var/run/apache2} ] && mkdir -p ${APACHE_RUN_DIR:-/var/run/apache2}
[ !-d${APACHE_RUN_DIR:-/var/run/apache2}/socks ] && mkdir_chown ${APACHE_RUN_USER:-www-data}${APACHE_RUN_DIR:-/var/run/apache2}/socks
[ !-d${APACHE_LOCK_DIR:-/var/lock/apache2} ] && mkdir_chown ${APACHE_RUN_USER:-www-data}${APACHE_LOCK_DIR:-/var/lock/apache2}case"$ARGV"in
start)
# ssl_scache shouldn't be here if we're just starting up.# (this is bad if there are several apache2 instances running)
rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache*
need_systemd=false
if [ -z"$APACHE_STARTED_BY_SYSTEMD" ] ;thencase"$(readlink -f /proc/1/exe)"in*systemd*)
need_systemd=true
;;
*)
;;
esacfiif$need_systemd;then# If running on systemd we should not start httpd without systemd# or systemd will get confused about the status of httpd.echo"Invoking 'systemctl start $APACHE_SYSTEMD_SERVICE'."echo"Use 'systemctl status $APACHE_SYSTEMD_SERVICE' for more info."
systemctl start "$APACHE_SYSTEMD_SERVICE"elseunset APACHE_STARTED_BY_SYSTEMD
$HTTPD${APACHE_ARGUMENTS} -k "$ARGV"fi
ERROR=$?
;;
stop|graceful-stop)
$HTTPD${APACHE_ARGUMENTS} -k "$ARGV"
ERROR=$?
;;
restart|graceful)
if$HTTPD${APACHE_ARGUMENTS} -t 2> /dev/null ;then$HTTPD${APACHE_ARGUMENTS} -k "$ARGV"else$HTTPD${APACHE_ARGUMENTS} -t
fi
ERROR=$?
;;
startssl|sslstart|start-SSL)
echo The startssl option is no longer supported.
echo Please edit httpd.conf to include the SSL configuration settings
echo and then use "apachectl start".
ERROR=2
;;
configtest)
$HTTPD${APACHE_ARGUMENTS} -t
ERROR=$?
;;
status)
get_status | awk ' /process$/ { print; exit } { print } '
;;
fullstatus)
get_status
;;
*)
$HTTPD${APACHE_ARGUMENTS}"$@"
ERROR=$?esacif [ "$ERROR"!= 0 ] ;thenecho Action \'"$@"\' failed.
echo The Apache error log may have more information.
fiexit$ERROR
And I'm afraid to say I can't see the source of the output is here, there is some usage output with -h:
apache2ctl -h
Usage: /usr/sbin/apache2 [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
-D name : define a name forusein<IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive": process directive before reading config files
-c "directive": process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed vhost settings
-t -D DUMP_RUN_CFG : show parsed run settings
-S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t -D DUMP_INCLUDES: show all included configuration files
-t : run syntax check for config files
-T : start without DocumentRoot(s) check
-X : debug mode (only one worker, do not detach)
Action '-h' failed.
The Apache error log may have more information.
The results from apache2ctl -t -D DUMP_VHOSTS -D DUMP_RUN_CFG match the result using -S.
The text was updated successfully, but these errors were encountered:
This is one for the back burner!
The output from
apache2ctl -S
looks like a suitable candidate for conversion into JSON, this is what I have on a development server:I guess the first thing to do would be to track down the code that generates this output, this is the content of
/usr/sbin/apache2ctl
on Debian:And I'm afraid to say I can't see the source of the output is here, there is some usage output with
-h
:The results from
apache2ctl -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
match the result using-S
.The text was updated successfully, but these errors were encountered: