提前谢谢。
我刚刚关注了digitalocean的教程:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts。 我完成了所有指令但是当我开始测试配置并从我的停车域添加A记录时,假设example.com和我的digitalocean vps地址是192.168.10.2。 在这个schenario中,我添加了3个不同的DocumentRoot这三个虚拟主机:
然后在我的停车域中添加3条不同的A记录,如下所示:
当我执行时,它发生如下:
我确信我在/ etc / apache2 / sites-available /(对于每个域).config中编写了正确的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>
答案 0 :(得分:0)
这是SSL问题IMO。域2按字母顺序排序高于3(优先级)。 Apache默认通过HTTPS(SSL)执行domaintwo。因此,域3的VH错误或未同时为两个协议启用。 我在猜测或多或少。希望对您有所帮助。