繁体   English   中英

无法设定ubuntu vhost档案

[英]Trouble setting ubuntu vhost file

好。 我正在尝试在ubuntu中设置我的配置文件。

当我查看sites-available文件夹时,我看到

  • 000-default.conf
  • ssl-default.conf

我有一个网站testsite.com,我需要为https配置虚拟主机

  1. 我可以在ssl-default.conf添加一个新的vhost部分吗? 我应该将整个文件复制到testsite.conf并在那里进行编辑吗?
  2. 我应该在哪里放置80端口的设置? 000-default.conf 如果我复制文件,是否需要在文件名中添加000 ,以便首先读取?
  3. 我在哪里可以将以前的信息放在默认文件中,例如( Allow Overrides等)

通常,VirtualHost的最佳位置是站点可用文件夹中的新文件。该文件的前缀是100-

sites-available/100-443-myproject.example.com这样的东西。

这样,当您使用ae2ensitea2dissite命令时,将在网站列表中启用默认值和myproject.example.com来启用或禁用。

000是默认虚拟主机的保留号,因为apache按字母顺序从启用站点的目录中读取文件,并且默认虚拟主机应该是第一个(默认Virtualhost捕获所有格式错误的主机HTTP标头,如果没有VirtualHost ServerName匹配) )。

如果您的VirtualHost用于端口80,则必须使用<VirtualHost *:80>配置指令(或<VirtualHost <my IP>:80> ,取决于NameVirtualHost设置)。 如果您的VirtualHost用于SSL端口,这是您的情况,则必须使用<VirtualHost *:443> ,并且必须通过a2ensitea2dissite确保此Virtualhost是定义的唯一启用SSL的VirtualHost(因此ssl-默认情况下不应启用)。

通过端口80, ServerName指令足以使apache决定应采用哪个VirtualHost。 使用端口443和SSL,这还不够,因为在可以匹配主机头/ ServerName之前进行了SSL协商。 因此多个SSL VH必须使用不同的端口,或使用新的系统SNI 这里所描述的例子

现在,对于AllowOverride您无需将其放在主配置中(但您可以将/etc/apache2/conf.d目录用于所有共享的Virtualhosts配置内容)。 您的VirtualHost可以包含足够的说明,例如:

<Virtualhost (....)
    ServerName (...)
    (...)
    <Directory />
      # Forbid .htaccess for all the filesystem directory tree
      AllowOverride None
    </Directory>

    <Directory /path/to/somewhere>
      # I am mad and I like slow apache server
      # So I want to allow .htaccess files
      # Instead of putting all the content of this .htaccess right here
      # in a Directory section
      AllowOverride All
    </Directory>
</VirtualHost>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM