Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu Apache2虚拟主机缺少文档根_Ubuntu_Apache2_Virtualhost_A Records - Fatal编程技术网

Ubuntu Apache2虚拟主机缺少文档根

Ubuntu Apache2虚拟主机缺少文档根,ubuntu,apache2,virtualhost,a-records,Ubuntu,Apache2,Virtualhost,A Records,先谢谢你 我只是在学习digitalocean的一个教程:。 我完成了所有指令,但当我开始测试配置并从我的停车域添加A记录时,比如example.com,我的digitalocean vps地址是192.168.10.2。 在这个schenario中,我添加了这3个虚拟主机和3个不同的DocumentRoot: /var/www/domainone.example.com/index.html /var/www/domaintwo.example.com/index.html /var/www/

先谢谢你

我只是在学习digitalocean的一个教程:。 我完成了所有指令,但当我开始测试配置并从我的停车域添加A记录时,比如example.com,我的digitalocean vps地址是192.168.10.2。 在这个schenario中,我添加了这3个虚拟主机和3个不同的DocumentRoot:

  • /var/www/domainone.example.com/index.html
  • /var/www/domaintwo.example.com/index.html
  • /var/www/domainthree.example.com/index.html
  • 然后在我的停车场域中,我添加了3个不同的A记录,如下所示:

  • 名称:domainone.example.com地址:192.168.10.2
  • 名称:domaintwo.example.com地址:192.168.10.2
  • 名称:domainthree.example.com地址:192.168.10.2
  • 当我执行时,它发生如下情况:

  • URLdomainone.example.com转到/var/www/domainone.example.com/index.html
  • URLdomaintwo.example.com转到/var/www/domaintwo.example.com/index.html
  • 但是这个URLdomainthree.example.com转到/var/www/domaintwo.example.com/index.html
  • 我确信我在/etc/apache2/sites available/(每个域)上写了一个正确的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
    
        <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>
    
    
    #ServerName指令设置请求方案、主机名和端口
    #服务器使用来标识自身。这在创建时使用
    #重定向URL。在虚拟主机的上下文中,服务器名
    #指定必须在请求的主机:标头中显示的主机名
    #匹配此虚拟主机。对于默认虚拟主机(此文件),此
    #该值不是决定性的,因为它被用作最后的宿主。
    #但是,必须为任何其他虚拟主机显式设置它。
    #服务器名www.example.com
    服务器管理员localhost@admin
    DocumentRoot/var/www/domaintwo.example.com/public
    ServerName domaintwo.example.com
    ServerAlias www.domaintwo.example.com
    #可用日志级别:trace8、…、trace1、调试、信息、通知、警告、,
    #错误、暴击、警报、紧急情况。
    #还可以为特定应用程序配置日志级别
    #模块,例如。
    #日志级别信息ssl:警告
    ErrorLog${APACHE_LOG_DIR}/error.LOG
    CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
    #对于conf/available/中的大多数配置文件
    #在全局级别启用或禁用,可以
    #仅包含一个特定虚拟主机的行。例如
    #以下行仅为此主机启用CGI配置
    #在使用“A2F”全局禁用后。
    #包括conf available/service-cgi-bin.conf
    斯伦金安
    
    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/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
    
        <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>
    
    
    #ServerName指令设置请求方案、主机名和端口
    #服务器使用来标识自身。这在创建时使用
    #重定向URL。在虚拟主机的上下文中,服务器名
    #指定必须在请求的主机:标头中显示的主机名
    #匹配此虚拟主机。对于默认虚拟主机(此文件),此
    #该值不是决定性的,因为它被用作最后的宿主。
    #但是,必须为任何其他虚拟主机显式设置它。
    #服务器名www.example.com
    服务器管理员localhost@admin
    DocumentRoot/var/www/domainthree.example.com/public
    ServerName域名域名tree.example.com
    ServerAlias www.domainthree.example.com
    #可用日志级别:trace8、…、trace1、调试、信息、通知、警告、,
    #错误、暴击、警报、紧急情况。
    #还可以为特定应用程序配置日志级别
    #模块,例如。
    #日志级别信息ssl:警告
    ErrorLog${APACHE_LOG_DIR}/error.LOG
    CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
    #对于conf/available/中的大多数配置文件
    #在全局级别启用或禁用,可以
    #仅包含一个特定虚拟主机的行。例如
    #以下行仅为此主机启用CGI配置
    #在使用“A2F”全局禁用后。
    #包括conf available/service-cgi-bin.conf
    斯伦金安
    SSLCertificateFile/etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile/etc/apache2/ssl/apache.key
    

  • 这是一个SSL问题。域2按字母顺序排序高于3(优先级)。Apache通过HTTPS(SSL)默认执行domaintwo。因此域3的VH错误,或者两个协议都未启用。
    我猜差不多。希望有帮助。

    我认为这是一个SSL问题。域2按字母顺序排序高于3(优先级)。Apache通过HTTPS(SSL)默认执行domaintwo。因此域3的VH错误,或者两个协议都未启用。
    我猜差不多。希望能有所帮助。

    我们能得到你的
    Apache
    virtualhost配置文件吗?@D4V1D我只是添加了virtualhost的配置文件,请看:)为什么没有domainone VirtualHost conf文件?您能在
    sudo apache2ctl-S
    的输出中验证是否一切都如您所期望的那样启用了吗?我们能为VirtualHosts提供您的
    Apache
    配置文件吗?@D4V1D我只是添加了VirtualHost的配置文件,请看:)为什么没有domainone VirtualHost conf文件?您能在
    sudo apache2ctl-S
    的输出中验证是否一切都如您所期望的那样启用了吗?我们能为VirtualHosts提供您的
    Apache
    配置文件吗?@D4V1D我只是添加了VirtualHost的配置文件,请看一看:)为什么没有d