【问题标题】:Chef set DocumentRoot in httpd recipe厨师在 httpd 配方中设置 DocumentRoot
【发布时间】:2025-04-20 02:30:02
【问题描述】:

使用https://community.opscode.com/cookbooks/httpd/versions/0.1.5

有人知道如何设置 DocumentRoot 吗?财产 ?

我正在使用

httpd_service "default" do
  listen_ports ['81']
  action :create
end

产生

ServerName centos65x64
ServerRoot /etc/httpd
PidFile /var/run/httpd/httpd.pid
User apache
Group apache
Timeout 400
ErrorLog /var/log/httpd/error_log
LogLevel warn
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
DefaultType None
HostnameLookups off

Listen 0.0.0.0:81
Include conf.d/*.conf
Include conf.d/*.load

在 httpd.conf 中,但我不确定如何设置 DocRoot。

【问题讨论】:

    标签: apache chef-infra cookbook


    【解决方案1】:

    cookbook 中包含的 httpd_config 资源会将 httpd 配置文件从模板部署到 httpd 实例的 config 目录,在运行 httpd 时包含该目录。您可以从这些模板配置您的 VirtualHosts 或主服务器,而不是说,设置食谱选择的节点属性并为您生成虚拟主机。

    这意味着您可以为您的 VirtualHost 配置创建一个Erubis 模板。有一个这样的配置in the cookbook tests...

    <VirtualHost *:81>
        ServerAdmin mike@patel.net
    
        DocumentRoot /var/www
        CustomLog /var/log/apache/mike-patel-access.log combined
    
        <Directory />
            Options FollowSymLinks
            AllowOverride None
        </Directory>
    
        <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
        </Directory>
    
        LogLevel warn
    </VirtualHost>
    

    【讨论】:

      最近更新 更多