애플맥

[macOS] Apache 가상호스트 Virtual Host 설정


[macOS] Apache 가상호스트 Virtual Host 설정




최초 작성일 : 2021-09-12 | 수정일 : 2021-10-15 | 조회수 : 542

웹 서버 환경 확인 


sudo vi /etc/apache2/httpd.conf


아래 부분 주석 해제

# Virtual hosts

Include /private/etc/apache2/extra/httpd-vhosts.conf

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so


가상 호스팅 파일 편집

sudo vi /etc/apache2/extra/httpd-vhosts.conf



샘플

ServerAdmin webmaster@dummy-host2.example.com

DocumentRoot '/usr/docs/dummy-host2.example.com'

ServerName dummy-host2.example.com

ErrorLog '/private/var/log/apache2/dummy-host2.example.com-error_log'

CustomLog '/private/var/log/apache2/dummy-host2.example.com-access_log' common



    ServerName abc.com

    ServerAlias www.abc.com

    DocumentRoot '/Users/zauin/Sites/abc'

    ErrorLog '/private/var/log/apache2/abc.com-error_log'

    CustomLog '/private/var/log/apache2/abc.com-access_log' common

    ServerAdmin zauin@tera.co.kr



만약 등록된 도메인으로 직접 접근하고 싶은 경우만 아래 과정 할 것 


sudo vi /etc/hosts


127.0.0.1 abc.com www.abc.com


아파치 재시작 

sudo apachectl restart




sudo vi /etc/apache2/extra/httpd-vhosts.conf



ServerName localhost

DocumentRoot /Library/WebServer/Documents/



sudo apachectl restart



User Group 변경 

sudo vi /etc/apache2/httpd.conf


uid=502(admin) gid=20(staff)


User admin

Group staff





중요

디렉토리 접근 권한 해제


sudo vi /etc/apache2/httpd.conf


아래 확인 


AllowOverride none

Require all denied <-- 이녀석때문에 안됨


그대로 두고


아래 추가 

/Users/zauin/Sites/abc>

    Options Indexes FollowSymLinks

    AllowOverride All

    Require all granted

Tags  #Apache  

닉네임:
댓글내용: