가상 호스팅 질문 및 요청드립니다

제가 우분투 hardy에서 서버를 운영하고 있습니다.

홈페이지는 2개를 운영하고 있는데요.

현재 sub1.abc.org 라는 도메인으로 서버를 돌리고 있고 사정상 abc.org는 외부 호스팅에서 돌리고 있으며 DNSever에서 같은 네임서버로 관리하고 있습니다. (현재 sub2.abc.org라는 서브 도메인을 DNSever에서 추가하고 ip도 sub1.abc.org와 같게 입력해 주었고 윈도우 서버에서 가상 호스트로 돌린적이 있습니다.)

동생이 홈페이지 한개를 구축하고 싶다고 해서 sub2.abc.org를 현재 우분투에서 가상 서버로 만들어주고 싶은데요. 예전 윈도우 서버와는 다르게 가상 호스팅이 잘 안되더군요.

그래서 제가 했던 과정과 함께 질문드립니다.

현재 저의 apache2.conf입니다.

[code:uwimk0t4]

Section 1: Global Environment

The directives in this section affect the overall operation of Apache,

such as the number of concurrent requests it can handle or where it

can find its configuration files.

ServerRoot: The top of the directory tree under which the server’s

configuration, error, and log files are kept.

NOTE! If you intend to place this on an NFS (or otherwise network)

mounted filesystem then please read the LockFile documentation (available

at <URL:http://httpd.apache.org/docs-2.1/mod/mpm_common.html#lockfile>);

you will save yourself a lot of trouble.

Do NOT add a slash at the end of the directory path.

ServerRoot "/etc/apache2"

The accept serialization lock file MUST BE STORED ON A LOCAL DISK.

#<IfModule !mpm_winnt.c>
#<IfModule !mpm_netware.c>
LockFile /var/lock/apache2/accept.lock
#</IfModule>
#</IfModule>

PidFile: The file in which the server should record its process

identification number when it starts.

This needs to be set in /etc/apache2/envvars

PidFile ${APACHE_PID_FILE}

Timeout: The number of seconds before receives and sends time out.

Timeout 30

KeepAlive: Whether or not to allow persistent connections (more than

one request per connection). Set to "Off" to deactivate.

KeepAlive on

MaxKeepAliveRequests: The maximum number of requests to allow

during a persistent connection. Set to 0 to allow an unlimited amount.

We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

KeepAliveTimeout: Number of seconds to wait for the next request from the

same client on the same connection.

KeepAliveTimeout 5

Server-Pool Size Regulation (MPM specific)

prefork MPM

StartServers: number of server processes to start

MinSpareServers: minimum number of server processes which are kept spare

MaxSpareServers: maximum number of server processes which are kept spare

MaxClients: maximum number of server processes allowed to start

MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule mpm_prefork_module>
ServerLimit 256
StartServers 5
MinSpareServers 10
MaxSpareServers 20
MaxClients 256
MaxRequestsPerChild 0
</IfModule>

worker MPM

StartServers: initial number of server processes to start

MaxClients: maximum number of simultaneous client connections

MinSpareThreads: minimum number of worker threads which are kept spare

MaxSpareThreads: maximum number of worker threads which are kept spare

ThreadsPerChild: constant number of worker threads in each server process

MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

These need to be set in /etc/apache2/envvars

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName: The name of the file to look for in each directory

for additional configuration directives. See also the AllowOverride

directive.

AccessFileName .htaccess

The following lines prevent .htaccess and .htpasswd files from being

viewed by Web clients.

<Files ~ "^&#46;ht">
Order allow,deny
Deny from all
</Files>

DefaultType is the default MIME type the server will use for a document

if it cannot otherwise determine one, such as from filename extensions.

If your server contains mostly text or HTML documents, "text/plain" is

a good value. If most of your content is binary, such as applications

or images, you may want to use "application/octet-stream" instead to

keep browsers from trying to display binary files as though they are

text.

DefaultType text/plain

HostnameLookups: Log the names of clients or just their IP addresses

e.g., www.apache.org (on) or 204.62.129.132 (off).

The default is off because it’d be overall better for the net if people

had to knowingly turn this feature on, since enabling it means that

each client request will result in AT LEAST one lookup request to the

nameserver.

HostnameLookups Off

ErrorLog: The location of the error log file.

If you do not specify an ErrorLog directive within a <VirtualHost>

container, error messages relating to that virtual host will be

logged here. If you do define an error logfile for a <VirtualHost>

container, that host’s errors will be logged there and not here.

ErrorLog /var/log/apache2/error.log

LogLevel: Control the number of messages logged to the error_log.

Possible values include: debug, info, notice, warn, error, crit,

alert, emerg.

LogLevel warn

Include module configuration:

Include /etc/apache2/mods-enabled/.load
Include /etc/apache2/mods-enabled/
.conf

Include all the user configurations:

Include /etc/apache2/httpd.conf

Include ports listing

Include /etc/apache2/ports.conf

The following directives define some format nicknames for use with

a CustomLog directive (see below).

If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i

LogFormat "%h %l %u %t &quot;%r&quot; %>s %b &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot;" combined
LogFormat "%h %l %u %t &quot;%r&quot; %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

ServerTokens

This directive configures what you return as the Server HTTP response

Header. The default is ‘Full’ which sends information about the OS-Type

and compiled in modules.

Set to one of: Full | OS | Minor | Minimal | Major | Prod

where Full conveys the most information, and Prod the least.

ServerTokens Full

Optionally add a line containing the server version and virtual host

name to server-generated pages (internal error documents, FTP directory

listings, mod_status and mod_info output etc., but not CGI generated

documents or custom error documents).

Set to "EMail" to also include a mailto: link to the ServerAdmin.

Set to one of: On | Off | EMail

ServerSignature On

Customizable error responses come in three flavors:

1) plain text 2) local redirects 3) external redirects

Some examples:

#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

Putting this all together, we can internationalize error responses.

We use Alias to redirect any /error/HTTP_<error>.html.var response to

our collection of by-error message multi-language collections. We use

includes to substitute the appropriate text.

You can modify the messages’ appearance without changing any of the

default HTTP_<error>.html.var files by adding the line:

Alias /error/include/ "/your/include/path/"

which allows you to create your own set of files by starting with the

/usr/share/apache2/error/include/ files and copying them to /your/include/path/,

even on a per-VirtualHost basis. The default include files will display

your Apache version number and your ServerAdmin email address regardless

of the setting of ServerSignature.

The internationalized error documents require mod_alias, mod_include

and mod_negotiation. To activate them, uncomment the following 30 lines.

Alias /error/ "/usr/share/apache2/error/"

<Directory "/usr/share/apache2/error">

AllowOverride None

Options IncludesNoExec

AddOutputFilter Includes html

AddHandler type-map var

Order allow,deny

Allow from all

LanguagePriority en cs de es fr it nl sv pt-br ro

ForceLanguagePriority Prefer Fallback

</Directory>

ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var

ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var

ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var

ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var

ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var

ErrorDocument 410 /error/HTTP_GONE.html.var

ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var

ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var

ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var

ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var

ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var

ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var

ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var

ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var

ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var

ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

AddDefaultCharset off

Include of directories ignores editors’ and dpkg’s backup files,

see README.Debian for details.

Include generic snippets of statements

Include /etc/apache2/conf.d/

Include the virtual host configurations:

#Include /etc/apache2/sites-enabled/

Enable PHPMyAdmin

Include /etc/phpmyadmin/apache.conf

<IfModule mod_evasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>

ServerName localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Directory /var/www/ >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

[/code:uwimk0t4]

지금 이상태로 /var/www/ 에서 sub1.abc.org가 잘 돌아가고 있습니다.

여기에 /var/www/forum/ 을 추가하고 sub2.abc.org를 가상으로 돌리려 합니다.

그래서 apache2.conf에 #Include /etc/apache2/sites-enabled/ 주석을 해제하고

site-available의 default의 내용을 수정한 후 sub2.abc.org 파일을 만든 내용은 각각 다음과 같습니다.

[b:uwimk0t4]default[/b:uwimk0t4]

[code:uwimk0t4]

NameVirtualHost *
<VirtualHost *>

   ServerAdmin admin@abc&#46;com

DocumentRoot /var/www

<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Directory /var/www/ >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
&lt;Directory &quot;/usr/lib/cgi-bin&quot;&gt;
	AllowOverride None
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	Order allow,deny
	Allow from all
&lt;/Directory&gt;

ErrorLog /var/log/apache2/error&#46;log

# Possible values include&#58; debug, info, notice, warn, error, crit,
# alert, emerg&#46;
LogLevel warn

CustomLog /var/log/apache2/access&#46;log combined
ServerSignature On

Alias /doc/ &quot;/usr/share/doc/&quot;
&lt;Directory &quot;/usr/share/doc/&quot;&gt;
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127&#46;0&#46;0&#46;0/255&#46;0&#46;0&#46;0 &#58;&#58;1/128
&lt;/Directory&gt;

</VirtualHost>

[/code:uwimk0t4]

[b:uwimk0t4]
sub2.abc.org
[/b:uwimk0t4]

[code:uwimk0t4]

<VirtualHost *>
ServerName sub2.abc.org
ServerAlias sub2.abc.org
ServerAdmin blur13th@gmail.com

    DocumentRoot /var/www/forum
    &lt;Directory /var/www/forum/&gt;
            Options Indexes FollowSymLinks MultiViews
            # pcw AllowOverride None
            AllowOverride All
            Order allow,deny
            allow from all
            # This directive allows us to have apache2's default start page
            # in /apache2-default/, but still have / go to the right place
            # Commented out for Ubuntu
            #RedirectMatch ^/$ /apache2-default/
    &lt;/Directory&gt;

    ErrorLog /var/log/apache2/forum/error&#46;log

    # Possible values include&#58; debug, info, notice, warn, error, crit,
    # alert, emerg&#46;
    LogLevel warn

    CustomLog /var/log/apache2/forum/access&#46;log combined
    ServerSignature On

</VirtualHost>

[/code:uwimk0t4]

그다음 명령어 a2ensite sub2.abc.org로 site-enabled와 연결하였습니다.

마지막으로 apache2를 재시작 해주었고요.

근데 이렇게 하면 sub1.abc.org와 sub2.abc.org 모두 작동하지 않습니다.

지금 뭐가 많이 꼬인 것 같아 위에서 한 방식이 맞다면 다시 해보려고 합니다. 잘못 된게 있으면 조언 부탁드리고요.

그리고 죄송하지만 쓰고 계시는 서버의 apache2.conf 파일과 site-available에 폴더에 있는 default 파일 좀 첨부해 주시면 고맙겠습니다. (처음부터 다시 해보고 싶습니다. 백업을 안해놔서…ㅡㅡ;:wink:

초보라 질문도 어렵군요…ㅎㅎ

설정파일 살펴 보니 한가지 apache2.conf 에서
#Include /etc/apache2/sites-enabled/
를 주석 푸시기 바랍니다.
Include /etc/apache2/sites-enabled/

그런 후 아파치 재시작 !

잘 될 듯 한데요 ;)

그리고 머 다 가능하게 하셔도 되지만. 사실 default.conf 에서 필요한 선언은
NameVirtualHost * 이거 하나 랍니다. 가상호스트 네임 선언

해결하였습니다…ㅎㅎ

말씀하신 주석은 제거했었는데 그 때문이 아니고 apache2.conf 셋팅을 잘못해서 그런 것 같습니다.

다 지우고 site-enabled만 이용해서 default와 함께 쓰니 되는군요.

혹시 궁금한 분들을 위해 말씀드리자면 위에 제가 나열한데로 그대로 하시면 잘 됩니다.