我正在尝试使用puppet和puppetlabs-apache模块(https://github.com/puppetlabs/puppetlabs-apache)配置apache。有谁知道是否可以将/ var / www的默认vhost的docroot更改为/ var / www / default?
谢谢!
答案 0 :(得分:3)
是的,有可能:
如vhost recipe中所示,
# Sample Usage:
#
# # Simple vhost definition:
# apache::vhost { 'site.name.fqdn':
# port => '80',
# docroot => '/path/to/docroot',
# }
默认vhost docroot与操作系统绑定,因此如果要在其他目录中运行默认主机,则应在apache声明中使用default_vhost => False
禁用它,然后声明apache::vhost
对象与你想要的conf
apache{
default_vhost => false,
...
}
apache::vhost{'mydefaulthost':
docroot => '/var/www/other',
...
}
答案 1 :(得分:2)
如果您没有默认虚拟主机,它将按字母顺序选择第一个虚拟主机。
这适用于我(在代码段中也留下了一些身份验证和别名用法位):
class {'apache':
default_vhost => false,
}
apache::vhost {'mydefault':
port => 443,
ssl => true,
#port => 80,
#ssl => false,
docroot => '/var/www/html',
directories => [
{
'path' => '/var/www/html',
'provider' => 'files',
},
{
'path' => '/media/builds',
'options' => 'Indexes FollowSymLinks MultiViews',
'allowoverride' => 'None',
'auth_type' => 'Basic',
'auth_name' => 'myrobotaccessonly',
'auth_basic_provider' => 'file',
'auth_user_file' => '/var/www/.mypasswdfile',
'auth_require' => 'user myrobotuser',
},
],
aliases => [
{
alias => '/builds',
path => '/media/builds',
},
],
}