공.부.하.자./우,분,투,
Ubuntu Apache2 Virtual Host 설정
깨드기쫑
2009. 10. 16. 04:17
우분투에서 Apache 가상 호스트 설정 방법
/etc/apache2/sites-available/default
~$ sudo vi /etc/apache2/sites-available/default
여기에 가상호스트를 설정한다.
참고로 여기 보이는 파일은 개인적인 것이며, 동일서버에 다른 포트로 접속하는 경우이다
<VirtualHost *:80>
ServerAdmin hanuli7@naver.com
ServerAlias cnlab.mju.ac.kr
DocumentRoot /var/www
ErrorLog /var/www/www-errlog.log
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
ServerAdmin hanuli7@naver.com
ServerAlias cnlab.mju.ac.kr
DocumentRoot /var/www
ErrorLog /var/www/www-errlog.log
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:5791>
ServerAdmin hanuli7@naver.com
DocumentRoot /home/hanuli7/www_root
ErrorLog /home/hanuli7/www_root/www-errlog.log
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/hanuli7/www_root>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:5791>
ServerAdmin hanuli7@naver.com
DocumentRoot /home/hanuli7/www_root
ErrorLog /home/hanuli7/www_root/www-errlog.log
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/hanuli7/www_root>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
이렇게 파일을 설정하고
/etc/apache/ports.conf 파일에 포트를 추가하여야 한다.
NameVirtualHost *:80
Listen 80
NameVirtualHost *:5791
Listen 5791
<IfModule mod_ssl.c>
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443
</IfModule>
Listen 80
NameVirtualHost *:5791
Listen 5791
<IfModule mod_ssl.c>
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443
</IfModule>
여기에서보면 80 포트와 5791 포트를 사용할 수 있게끔 열어주었다.
아마도 직접 해본것은 아니지만
혹시나 같은 포트로 들어와서도 웹사이트 주소에 따라 다른 페이지 접속을 원한다면
아마도 위에 보였던 /etc/apache2/sites-available/default 에서 가상호스트 조금만 변경하면 될듯?
그건 나중에 다시 해보고 올려야겠다.