ⓟrogramming
아파치 가상호스트 설정 예제.
가이브
2008. 11. 3. 16:17
Apache virtual host..
Okay I got it going on my box just using localhost and listen on different ports.
The Document root had to start from root /var/www/html/...
In my directories I have
/var/www/html/test1/index.html
/var/www/html/test2/index.html
I configured appache to also listen to port 8000
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
Listen 8000
Then modified the virtual hosts to point to the different folders...
NameVirtualHost *:80
NameVirtualHost *:8000
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/test1
ServerName test1.com
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot /var/www/html/test2
ServerName test2.com
</VirtualHost>
Restart apache, open a browser and voila - http://localhost displays /test1/index.html and http://localhost:8000 displays /test2/index.html
Okay I got it going on my box just using localhost and listen on different ports.
The Document root had to start from root /var/www/html/...
In my directories I have
/var/www/html/test1/index.html
/var/www/html/test2/index.html
I configured appache to also listen to port 8000
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
Listen 8000
Then modified the virtual hosts to point to the different folders...
NameVirtualHost *:80
NameVirtualHost *:8000
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/test1
ServerName test1.com
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot /var/www/html/test2
ServerName test2.com
</VirtualHost>
Restart apache, open a browser and voila - http://localhost displays /test1/index.html and http://localhost:8000 displays /test2/index.html
- http://fedoraforum.org/forum/archive/index.php/t-147521.html
반응형