先感谢您。
我只是按照 digitalocean 的教程:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts .
我完成了所有指令,但是当我开始测试配置并从我的 parking 域添加一条 A 记录时,比如说 example.com,我的 digitalocean vps 地址是 192.168.10.2。
在这个方案中,我添加了这 3 个具有 3 个不同 DocumentRoot 的虚拟主机:
然后在我的 parking 域中添加 3 个不同的 A 记录,如下所示:
当我执行时,它发生如下:
我确定我在/etc/apache2/sites-available/(for each domain).config 处写了一个正确的 documentRoot 并重新启动 apache2 服务
再次感谢你
编辑
<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
<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>
最佳答案
这是 IMO 的 SSL 问题。域 2 按字母顺序排序高于 3(优先级)。 Apache 默认通过 HTTPS (SSL) 执行 domaintwo。所以域 3 的 VH 是错误的,或者没有为这两个协议(protocol)启用。
我猜测或多或少。希望能帮助到你。
关于ubuntu - Apache2 虚拟主机缺少文档根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30934097/