요세미티에서 Apache 2.4를 실행하고 있습니다.
이것은 나의 /private/etc/apache2/httpd.conf
ServerName 127.0.0.1:80
DocumentRoot "/Library/WebServer/Documents/home_www/"
<Directory "/Library/WebServer/Documents/home_www">
Options Multiviews FollowSymLinks
MultiviewsMatch Any
AllowOverride All
Order allow,deny
Allow from all
</Directory>
이 설정을 내가 사용할 수 있습니다 http://127.0.0.1
및 http://localhost
다음 웹 브라우저에서이 날을 지시 /Library/WebServer/Documents/home_www/index.html
평소와 같이
그런 다음 Include /private/etc/apache2/extra/httpd-vhosts.conf
내 컴퓨터에서 vhost를 사용하고 싶기 때문에 추가했습니다.
이것은 나의 /private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin jeud@hotmail.com
ServerName tutor4dev.local
DocumentRoot "/Library/WebServer/Documents/home_www/xxx"
</VirtualHost>
sudo apachectl -S
vhost 구성을 표시하는 데 사용하려고했는데 결과가 있습니다.
VirtualHost configuration:
*:80 xxx.local (/private/etc/apache2/extra/httpd-vhosts.conf:28)
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents/home_www/"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex proxy: using_defaults
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/private/var/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="_www" id=70
Group: name="_www" id=70
내가 사용할 수있는 http://xxx.local
액세스 /Library/WebServer/Documents/home_www/xxx/index.html
(가상 호스트)하지만 가상 호스트를 추가 한 후, http://127.0.0.1
그리고 http://localhost
나에게 직접 또한 /Library/WebServer/Documents/home_www/xxx/index.html
대신/Library/WebServer/Documents/home_www/index.html
그것을 고치는 방법을 안내하십시오 감사합니다
답변
VirtualHost는 하나 뿐이며 그 안에 *가 있습니다 ( <VirtualHost *:80>
). 주 서버는 요청에 응답하지 않습니다. 이름 기반 가상 호스트의 경우 기본 서버 인 첫 번째 가상 호스트가 모든 요청을 처리합니다. 다음과 같이 구성 파일에서 다른 가상 호스트보다 먼저 나타나야하는 새 가상 호스트를 작성해야합니다.
# Main server, catches all requests that do not correspond to a ServerName/Alias
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot "/Library/WebServer/Documents/home_www/"
...
</VirtualHost>
아파치 문서 에서 더 많은 정보