..png)
vhost.conf , etc/httpd/vhost.d/에 있음
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName localhost
ServerAlias localhost.example.com
DocumentRoot /var/www/html/example.com/public_html/
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.org
ServerAlias www.example.org
DocumentRoot /var/www/html/example.org/public_html/
ErrorLog /var/www/html/example.org/logs/error.log
CustomLog /var/www/html/example.org/logs/access.log combined
</VirtualHost>
httpd.conf, 기본값 설정, 끝에 추가됨:
Include /etc/httpd/vhosts.d/*.conf
루트 디렉터리:
DocumentRoot "/var/www/html"
위 폴더에 생성된 가상호스트에 대한 각각의 디렉터리입니다. 권한이 모두 올바르게 보입니다. 각 public_html
디렉토리에 Index.php 파일이 있습니다. 그러나 이제 localhost를 실행하면 기본 Apache 2 페이지로 이동하게 됩니다. Include /etc/httpd/vhosts.d/*.conf
기본 디렉토리에서 필요에 따라 webserver works 줄을 제거하고 거기에 넣은 인덱스 파일을 제공해야 합니다.
답변1
입력한 내용으로 볼 때 구문 오류가 있는 것 같지 않습니다. 따라서 /etc/hosts 파일에서 다음을 수행하십시오(서버에서 직접 수행하는 경우).
127.0.0.1 example.org
127.0.0.1 example.com
또는 PC의 호스트 파일에서:
YOURSERVERIP example.org
YOURSERVERIP example.com
그리고 localhost 대신 해당 도메인을 찾아보세요.
Apache 웹 페이지만 표시되는 이유는 Apache가 어디로 가야 하는지 알아야 하기 때문입니다. 아직 DNS 설정이 없기 때문에 문제의 호스트 이름으로 Apache에 아무 것도 전송되지 않으므로 기본값은 문서 루트입니다. .
답변2
포함 행이 VirtualHosts 뒤에 있으므로 포함된 가상 호스트 중 하나가 새 가상 호스트를 재정의하는 것으로 추측됩니다. "httpd -S"는 무엇을 말합니까? ("httpd"가 아닐 수도 있고, "apache2" 또는 다른 것일 수도 있습니다). -S 플래그는 구성한 모든 가상 호스트를 표시하고 디버깅에 도움이 됩니다.
포함 줄을 제거하여 새 블록이 작동하는지 확인할 수 있습니다. 오류 로그를 확인하여 구성 파일에 대한 경고가 있는지 확인할 수도 있습니다.