0

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

Selphiron
  • 897
  • 1
  • 12
  • 30

1 Answers1

1

You can use the apachectl -S command or the httpd -S command (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.

  • Thanks, I updated my question after following your suggestion, please take a look. – Selphiron Jul 23 '23 at 15:15
  • this [link](https://stackoverflow.com/questions/27152943/how-can-i-view-the-complete-httpd-configuration) might be able to help. as far as i know you cant restore the source of the symlink from the target. – AlirezaPourchali Jul 23 '23 at 15:57
  • see `apachectl -h` for the `-D` option. but i dont think you can retrieve the exact config like nginx – AlirezaPourchali Jul 23 '23 at 16:01