提前感谢。
我只是遵循数字海洋的教程:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts。我完成了所有说明,但是当我开始测试配置并从我的停车域添加 A 记录时,假设 example.com,我的数字海洋 vps 地址是 192.168.10.2。在此 schenario 中,我添加了这 3 个虚拟主机和 3 个不同的 DocumentRoot:
然后在我的停车场域中,我添加了3个不同的A记录,如下所示:
当我执行时,它发生如下:
我确信我在/etc/apache2/sitesavailable/(每个域)上写了一个正确的documentRoot。配置并重新启动apache2服务
再次感谢你们
编辑
>
这是针对/etc/apache2/sites available/domaintwo.example.com.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin localhost@admin
DocumentRoot /var/www/domaintwo.example.com/public
ServerName domaintwo.example.com
ServerAlias www.domaintwo.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key
这是针对 /etc/apache2/sites-available/domainthree.example.com.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin localhost@admin
DocumentRoot /var/www/domainthree.example.com/public
ServerName domainthree.example.com
ServerAlias www.domainthree.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>
这是一个SSL问题IMO。域2的字母顺序高于3(优先级)。Apache通过HTTPS(SSL)默认执行domaintwo。因此,域3的VH是错误的,或者两种协议都未启用。我多多少少在猜测。希望有帮助。
术语"虚拟主机"是指在一个机器上运行多个网站(比如:www.company1.com和www.company2.com)。如果每个网站拥有不同的IP地址,则虚拟主机可以是"基于IP"的;如果只有一个IP地址,也可以是"基于主机名"的,其实现对最终用户是透明的。 Apache是率先支持基于IP的虚拟主机的服务器之一。1.1及其更新版本同时支持基于IP和基于主机名的虚拟主机,今后,不同的虚拟主机有时会
OS:centOS 6.3最终版 我已经安装了mysql和apache2(httpd)包,并更改了/etc/httpd/conf/httpd.conf中的配置,如下所示: 所有服务器名称和服务器别名都工作正常,我可以访问 3 个页面。 但是当我试图通过服务器的ip访问一个页面时,奇怪的事情发生了(至少对我来说)。apache2返回给我第一个定义的virtualHost(在这个例子中是wordpre
两个虚拟主机(纯静态-html 支持) - Two Virtual Hosts, Serving Static Files http { : server { : listen 80; : server_name www.domain1.com; : access_log logs/domain1.access.log main; : location / {
主要内容:Apache虚拟主机类型,3. 虚拟主机配置示例Apache Web服务器可以在SAME服务器上托管多个网站。每个网站不需要单独的服务器机器和apache软件。这可以使用虚拟主机或VHost的概念来实现。 要在Web服务器上托管的任何域(网站应用)都将在apache配置文件中具有单独的条目。 Apache虚拟主机类型 Apache虚拟主机类型有两种 - 基于名称的虚拟主机 基于地址或基于IP的虚拟主机。 1. 基于名称的虚拟主机 基于名称的虚拟
虚拟主机是路由配置中的顶层配置。每个虚拟主机都有一个逻辑名称以及一组域列表,会根据传入请求的主机头路由到对应的域。这允许为单个监听器配置多个顶级域的路径树。一旦基于域选择了虚拟主机,就会进行路由处理,以便查找并路由到相应上游集群或者是否执行重定向。 { "name": "...", "domains": [], "routes": [], "require_ssl": "...",
虚拟主机名使用server_name指令定义,用于决定由某台虚拟主机来处理请求。具体请参考《nginx如何处理一个请求》。虚拟主机名可以使用确切的名字,通配符,或者是正则表达式来定义: server { listen 80; server_name example.org www.example.org; ... } server { liste