[英]Trouble setting ubuntu vhost file
好。 我正在尝试在ubuntu中设置我的配置文件。
当我查看sites-available
文件夹时,我看到
000-default.conf
ssl-default.conf
我有一个网站testsite.com,我需要为https配置虚拟主机
ssl-default.conf
添加一个新的vhost部分吗? 我应该将整个文件复制到testsite.conf并在那里进行编辑吗? 000-default.conf
? 如果我复制文件,是否需要在文件名中添加000
,以便首先读取? Allow Overrides
等) 通常,VirtualHost的最佳位置是站点可用文件夹中的新文件。该文件的前缀是100-
。
像sites-available/100-443-myproject.example.com
这样的东西。
这样,当您使用ae2ensite
和a2dissite
命令时,将在网站列表中启用默认值和myproject.example.com
来启用或禁用。
000
是默认虚拟主机的保留号,因为apache按字母顺序从启用站点的目录中读取文件,并且默认虚拟主机应该是第一个(默认Virtualhost捕获所有格式错误的主机HTTP标头,如果没有VirtualHost
ServerName
匹配) )。
如果您的VirtualHost用于端口80,则必须使用<VirtualHost *:80>
配置指令(或<VirtualHost <my IP>:80>
,取决于NameVirtualHost
设置)。 如果您的VirtualHost用于SSL端口,这是您的情况,则必须使用<VirtualHost *:443>
,并且必须通过a2ensite
和a2dissite
确保此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.