Apache2 +禁用默认虚拟服务器

这是我第一次尝试自己设置服务器。

到目前为止,一切都很好。 我添加了一个新的虚拟服务器,并更改了我的域的Alogging,现在按预期工作。

但是:我想“阻止”访问默认的www目录(在我的情况下var/www )。 现在,当我input服务器IP而不是域,我到达默认的www dir – 我想禁用它。

我不想设置redirect,但只是禁止用户,search引擎等浏览任何东西时,他们去http://myip/

目前我正在做的诀窍是添加一个空的index.html ,但我想实际上阻止所有的请求,只允许访问我的域名(他们是在像“ var/www/sites/domain.com/wwwvar/www/sites/domain.com/www ) )

我希望你明白我的意思 – 我的英语很烂:/

PS,因为我安装了webmin,我通过http://myIp:webminPort访问它 – 我想我其实只想阻止端口80,但不知道这个…

您需要保持80端口开放,因为您的domain.com/www虚拟主机的所有内容也都通过80。

有一个由Apache默认的虚拟主机设置,你只需要在你的httpd.conf注释掉它。

编辑webmin中的configuration:

  Webmin -> Servers -> Apache Website -> Global Configuration 

给它一个缓慢的阅读,你会发现默认的虚拟主机代码块,只是注释掉。 这是值得的,因为你可能以后想调整设置。

Andre(OP)确定默认的虚拟主机定义是在/ sites-enabled / default-000中

这里是你正在寻找的部分:

 ### Section 2: 'Main' server configuration # # The directives in this section set up the values used by the 'main' # server, which responds to any requests that aren't handled by a # <VirtualHost> definition. These values also provide defaults for # any <VirtualHost> containers you may define later in the file. # # All of these directives may appear inside <VirtualHost> containers, # in which case these default settings will be overridden for the # virtual host being defined. # 

使用散列注释掉第2节中的这些指令:

 #ServerName #<Directory /> #<Directory> #---comment out all contents of this directory block--- #<Directory /var/www/html> #---comment out all contents of this directory block--- #</Directory> #DocumentRoot