I accidentally deleted mysite.conf in /etc/apache2/sites-available (instead of the sym link in /etc/apache2/sites-enabled). The site is still enabled, because I did not reload nor restart apache2 yet. I need to retrieve that config. With nginx, I could simply put nginx -T, which would show me the contents of all loaded .conf files. What can I do with apache2?
Edit:
When I try apachectl -S, I don't get all loaded configs. I am looking for the .conf that contains the VirtualHost with port 80. I only get the .conf, that contains the VirtualHost with port 8000.
[Sun Jul 23 17:04:55.865781 2023] [tile:warn] [pid 11677] Could not determine host name of server to configure tile-json request. Using localhost instead
[Sun Jul 23 17:04:55.865832 2023] [tile:notice] [pid 11677] Loading tile config rides-quality-segments at /tiles/rides-quality-segments/ for zooms 0 - 20 from tile directory /var/lib/mod_tile with extension .png and mime type image/png
VirtualHost configuration:
*:8000 mydomain.com (/etc/apache2/sites-enabled/othersite.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
the tile:warn and tile:notice seems to be in a loop. Every time I rerun apachectl -S the time stamp is of the actual second.
Here is the output of sudo lsof -i -P -n | grep LISTEN to show, that there is indeed a .conf, that contains a VirtualHost with a port of 80:
apache2 7720 root 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 10135 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 10136 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 10137 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 10138 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 10139 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
apache2 26795 www-data 4u IPv6 1204364228 0t0 TCP *:80 (LISTEN)
python 12777 admin 6u IPv4 1205645383 0t0 TCP *:8000 (LISTEN)
ps -aux shows, that the commands of all the pIDs shown in the list above are: /usr/sbin/apache2 -k start
Also /var/lib/apache2/site/enabled_by_admin contains two empty files:
mysite.conf and othersite.conf.
However, only the configuration of othersite.conf is shown by apachectl -S
You can use the
apachectl -Scommand or thehttpd -Scommand (depending on your distribution) to print the current running configuration.This will show you the virtual host configuration syntax for all of the virtual hosts that are currently configured in Apache.