Apache2是否有类似于nginx -T的功能?

huangapple go评论53阅读模式
英文:

Does apache2 have an equivalent to nginx -T?

问题

抱歉,我只会回答你的请求,不会提供其他内容。以下是你要的翻译:

"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 -auxshows, 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"

英文:

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

答案1

得分: 1

你可以使用 apachectl -S 命令或者 httpd -S 命令(根据你的发行版而定)来打印当前运行的配置。

这将会显示当前在Apache中配置的所有虚拟主机的虚拟主机配置语法。

英文:

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.

huangapple
  • 本文由 发表于 2023年7月23日 16:07:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747221.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定