【问题标题】:How to forward port in apache2 cookbook如何在 apache2 食谱中转发端口
【发布时间】:2016-04-06 04:33:05
【问题描述】:

我尝试在 apache 食谱中使用以下代码将默认端口 80 映射到 443,但是在运行厨师时仍然出现错误。您能否就此提出建议。我试图映射到端口 #80 以外的端口,因为我的食谱中也有 nginx 配方,所以想设置 apache2 来监听差异端口 -

* apache/attribute/default.rb

default['apache']['dir']          = '/etc/apache2'
default['apache']['listen_ports'] = [ '80','443' ]

* apache/recipes/default.rb

package "apache2" do
    action :install
end

service "apache2" do
    action [:enable, :start]
end


template "/var/www/index.html" do
    source "index.html.erb"
    mode "0644"
end

Vagrant provision error -
    ================================================================================
    ==> default:     
    ==> default: Error executing action `start` on resource 'service[apache2]'
    ==> default:     
================================================================================

    ==> default:     
    ==> default: Mixlib::ShellOut::ShellCommandFailed
    ==> default:     
    ==> default: ------------------------------------
    ==> default:     
    ==> default: Expected process to exit with [0], but received '1'


This time I had used  ==> 
attribute/default.rb with below content but still getting error -
default['apache']['dir']          = '/etc/apache2'
default['apache']['listen_ports'] = [ '81’ ]

Error    
==> default: STDOUT: * Starting web server apache2
==> default: 
==> default:     Action 'start' failed.
==> default:     The Apache error log may have more information.
==> default:        ...fail!
==> default:     STDERR: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
==> default:     (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

【问题讨论】:

    标签: apache chef-infra chef-recipe cookbook


    【解决方案1】:

    listen_ports 不是映射,它设置要监听的端口。如果您不想在 80 上收听,请不要将其包含在该数组中。

    【讨论】:

    • 请在问题中添加日志内容,它会在此处重新格式化为一行。
    • 更改后出现差异错误,并在上述问题中添加了错误消息。
    • 新的错误是说有东西已经在监听那个端口 (80),所以某处端口 80 仍在使用中。
    • 我认为您对自己使用的食谱感到困惑。你提到了apache2 食谱,但你的路径说apache 非常不同。您要使用的是httpd。
    • 在端口 80 我有 nginx 监听,因此我试图在端口 81 上映射 apahce2。我有流浪机器 ubuntu,所以我没有使用 httpd,而是使用 apache。我尝试使用 default['apache2']['listen_ports'] = [ '81' ] 但仍然是同样的错误。这次我也手动更改了 /etc/apache2/sites-enabled/000-default.conf 并设置 和 /etc/apache2/ports.conf 并设置 Listen 81 然后它可以工作,但我期待这将由厨师以自动方式完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-22
    • 2013-08-28
    • 2012-08-07
    • 1970-01-01
    相关资源
    最近更新 更多