본문 바로가기

Server/Apache

[Apache] VirtualHost 설정

<VirtualHost> Directive

Description:Contains directives that apply only to a specific hostname or IP address
Syntax:<VirtualHost addr[:port] [addr[:port]] ...> ... </VirtualHost>
Context:server config
Status:Core
Module:core

<VirtualHost> and </VirtualHost> are used to enclose a group of directives that will apply only to a particular virtual host. Any directive that is allowed in a virtual host context may be used. When the server receives a request for a document on a particular virtual host, it uses the configuration directives enclosed in the <VirtualHost> section. Addr can be any of the following, optionally followed by a colon and a port number (or *):

  • The IP address of the virtual host;
  • A fully qualified domain name for the IP address of the virtual host (not recommended);
  • The character *, which acts as a wildcard and matches any IP address.
  • The string _default_, which is an alias for *
<VirtualHost 10.1.2.3:80>
  ServerAdmin webmaster@host.example.com
  DocumentRoot "/www/docs/host.example.com" : 실행시킬 프로젝트
  ServerName host.example.com
  ErrorLog "logs/host.example.com-error_log"
  TransferLog "logs/host.example.com-access_log"
</VirtualHost>


ServerName Directive

Description:Hostname and port that the server uses to identify itself
Syntax:ServerName [scheme://]domain-name|ip-address[:port]
Context:server config, virtual host
Status:Core
Module:core

The ServerName directive sets the request scheme, hostname and port that the server uses to identify itself.


원문 : https://httpd.apache.org/docs/current/en/mod/core.html#virtualhost