
Apache가 127.0.0.1에 대한 요청만 처리하여 다른 응용 프로그램에 127.0.0.2 등을 사용할 수 있도록 하고 싶습니다. 그래서 /etc/apache2/sites-enabled/000-default.conf를 다음으로 변경해 보았습니다.
<VirtualHost 127.0.0.1:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
그런 다음 Apache를 다시 시작했지만 작동하지 않습니다. 다른 가상 호스트 규칙은 없으며 출력은 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
답변1
그만큼Listen
지시문은 Apache httpd가 바인드해야 하는 주소/포트 조합을 구성하는 데 사용됩니다(또는듣다원한다면).
포트만 지정하면(주소 없음) 모든 주소에 대해 지정된 포트에 바인딩된다는 의미입니다.
그만큼VirtualHost
반면에 지시문은 요청에 응답하는 방법(예: 서비스할 콘텐츠 등)에 대한 구성의 일부입니다.
이 컨텍스트에 지정된 주소/포트는 Apache httpd가 이를 사용하려고 시도해야 하는 들어오는 요청을 선택하는 데 사용됩니다 VirtualHost
.
Apache httpd가 에만 바인딩하도록 하려면 127.0.0.1:80
다음과 같은 유일한 Listen
지시문을 사용하면 됩니다.
Listen 127.0.0.1:80