我希望Apache只处理127.0.0.1的请求,以便在其他应用程序中使用127.0.0.2等,因此我尝试将/ etc /apache2/sites启用/000-default.conf更改为
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined然后我重新启动了Apache,但是它不起作用。没有其他vhost规则,apachectl -S的输出如下:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
127.0.0.1:80 localhost (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
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发布于 2019-07-21 18:46:00
Listen指令用于配置Apache应该绑定到的地址/端口组合(如果愿意的话)。当只指定一个端口(没有地址)时,这意味着绑定到所有地址的指定端口。
另一方面,VirtualHost指令是如何响应请求的配置的一部分(比如要服务的内容等等)。在此上下文中指定的地址/端口用于选择Apache甚至应该尝试使用此VirtualHost的传入请求。
如果您只希望Apache只绑定到127.0.0.1:80,您将执行类似的操作,作为您唯一的Listen指令:
Listen 127.0.0.1:80https://serverfault.com/questions/976106
复制相似问题