Apache下同一个IP配置多个虚拟主机

Apache下同一个IP配置多个虚拟主机


NameVirtualHost192.100.100.1


ServerAdminnjzadmin@https://www.360docs.net/doc/cd7268644.html,
DocumentRoot/wwwroot
https://www.360docs.net/doc/cd7268644.html,
ErrorLoglogs/https://www.360docs.net/doc/cd7268644.html,-error_log
Customloglogs/a-Access_logcommon



ServerAdminsonymusic@https://www.360docs.net/doc/cd7268644.html,
DocumentRoot/wwwroot2
https://www.360docs.net/doc/cd7268644.html,
ErrorLoglogs/https://www.360docs.net/doc/cd7268644.html,-error_log
CustomLoglogs/https://www.360docs.net/doc/cd7268644.html,-access_logcommon



Apache配置httpd.conf设置一个IP两个域名的方法 如何让两个域名对应同一个IP,然后能识别出不同的网站

本身Virtual Hosting技术分IP-based和Host-based。IP-based Virtual Hosting是指运行网站服务器的计算机有多个 IP地址(IP Address),访问不同的IP地址就可以取得不同的网站。Host-based Virtual Hosting则是指在DNS上多个网域 都是指向同一个IP地址,网页浏览器(WWW Browser)透过HTTP协定告知网页服务器要访问那个网站。


一个IP地址,多域名配置:

Listen 80

NameVirtualHost 61.139.72.10



DocumentRoot /var/www/html/https://www.360docs.net/doc/cd7268644.html,

ServerName https://www.360docs.net/doc/cd7268644.html,





DocumentRoot /var/www/html/https://www.360docs.net/doc/cd7268644.html,

CustomLog /var/www/html/logs/home-access_log common

ServerName https://www.360docs.net/doc/cd7268644.html,



多IP多域名配置:



DocumentRoot "/usr/local/apache/a"

ServerName https://www.360docs.net/doc/cd7268644.html,

ServerAlias https://www.360docs.net/doc/cd7268644.html,

DirectoryIndex index.html index.php



NameVirtualHost 192.168.1.2:80



DocumentRoot "/usr/local/apache/b"

ServerName https://www.360docs.net/doc/cd7268644.html,

ServerAlias https://www.360docs.net/doc/cd7268644.html,

DirectoryIndex index.php





DocumentRoot "/usr/local/apache/c"

ServerName https://www.360docs.net/doc/cd7268644.html,

ServerAlias https://www.360docs.net/doc/cd7268644.html,

DirectoryIndex index.php



------------------------------------------------------------------------------------------


# 在ServerName后加上你的网站名称 ServerName https://www.360docs.net/doc/cd7268644.html, # 如果你想多个网站名称都取得相同的网站,可以加在ServerAlias后加上其他网站别名。 # 别名间以空格间开。 ServerAlias https://www.360docs.net/doc/cd7268644.html, https://www.360docs.net/doc/cd7268644.html, # 在ServerAdmin后加上网站管理员的电邮地址,方便别人有问题是可以联络网站管理员。 ServerAdmin webmaster@https://www.360docs.net/doc/cd7268644.html, # 在DocumentRoot后加上存放网站内容的目录路径 DocumentRoot /var/www/https://www.360docs.net/doc/cd7268644.html, Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Allow from all ErrorLog /var/log/httpd/error.log # Possible values i

nclude: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/httpd/access.log combined ServerSignature On官方给的例子:https://www.360docs.net/doc/cd7268644.html,/docs/2.2/vhosts/examples.html

相关文档
最新文档