2019년 1월 24일 목요일

[apache]가상호스트 설정 방법

1. https-vhost 파일을 연다.

 <Directory "프로젝트들의 최상단 경로">    ex) C:/dev/projects
Order deny,allow
Deny from all
Allow from 허용할 아이피 주소 (복수개 사용)
Allow from ...
        Allow from ...
        ...
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>


C:/dev/projects 하위 프로젝트를 접근하기 위한 설정

<VirtualHost *:80>
ServerName host.a.com
        ServerAlias www.a.com
DocumentRoot "C:/dev/projects/a/"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php\?/$1 [L]
</VirtualHost>

<VirtualHost *:80>
ServerName host.b.com                                       //서버명, 알리아스둘다접근
        ServerAlias www.b.com
DocumentRoot "C:/dev/projects/b/"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f                  //파일이 아닐경우
RewriteCond %{REQUEST_FILENAME} !-d                 //디렉토리가 아닐경우
RewriteRule ^(.*)$ /index.php\?/$1 [L]                    // index.php 로드한다.
</VirtualHost>

<VirtualHost *:80>
ServerName host.c.com
        ServerAlias www.c.com
DocumentRoot "C:/dev/projects/c/"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php\?/$1 [L]
</VirtualHost>


위 설정으로 하면 로컬의 경우 호스트 파일에 등록하고 하나의 아파치에서 a,b,c
php 웹 사이트 3개를 구동 가능 하게 한다.



예외 설정

css 라는 경로가 포함된경우 index.php 를 태우기 싫다면 아래와 같은 Cond 를 추가한다.

RewriteCond %{REQUEST_URI} !^/css/(.*)$









댓글 없음:

댓글 쓰기

[OS]리눅스서버 WAS 관련 권한 관리

[Best Practice] Linux 서버 WAS 권한 체계 구축 가이드 리눅스 환경에서 다수의 운영자가 WAS(Tomcat, Nginx 등)를 공동 관리할 때 발생하는 권한 꼬임(Permission Denied) 문제를 방지하기 위한 표준 설정...