Apache 继续存在于 chef 实例中

Apache continues to exist in a chef instance

我目前是运行 vagrant 的厨师厨房,以测试我的自定义食谱以供以后在 AWS OpsWorks 中使用。

出于某种原因,nginx 无法启动((98:地址已在使用中)),因为 apache2 服务在我的食谱中启动 nginx 之前启动 运行。令人困惑的是我没有指定要安装的 apache2。但是我已经尝试在我的 nginx 启动食谱之前添加它。但无济于事。 我已经多次尝试破坏我的 vagrant 机器,但 apache2 仍然存在。

我真的对这种行为感到困惑,如果有人知道为什么会这样,我将不胜感激。

流浪机是运行ubuntu16.04

recipes/setup.rb

...
package "apache2" do
    action :purge
end
service "apache2" do
    supports :status => true
    action :stop
    action :disable
    retries 5
end
# enable the server block we just created
    nginx_site 'api' do
    action :enable
    notifies :reload, 'service[nginx]'
end

metadata.rb

...
version '0.1.0'
depends 'apt', '~> 6.0'
depends 'locale', '~> 2.0.0'
depends 'php', '~> 2.2.0'
depends 'chef_nginx', '~> 5.0.7'
depends 'application', '~> 5.1.0'

Berksfile.lock

DEPENDENCIES
  api
    path: .
    metadata: true

GRAPH
  application (5.1.0)
    poise (~> 2.4)
    poise-service (~> 1.0)
  apt (6.0.0)
  build-essential (8.0.0)
    mingw (>= 1.1)
    seven_zip (>= 0.0.0)
  chef_nginx (5.0.7)
    build-essential (>= 0.0.0)
    compat_resource (>= 12.16.3)
    ohai (>= 4.1.0)
    runit (>= 1.6.0)
    yum-epel (>= 0.0.0)
    zypper (>= 0.0.0)
  compat_resource (12.16.3)
  iis (5.0.5)
    windows (>= 1.34.6)
  locale (2.0.0)
  mingw (1.2.5)
    compat_resource (>= 12.16.3)
    seven_zip (>= 0.0.0)
  api (0.1.0)
    application (~> 5.1.0)
    apt (~> 6.0)
    chef_nginx (~> 5.0.7)
    locale (~> 2.0.0)
    php (~> 2.2.0)
  mysql (8.2.0)
  ohai (4.2.3)
    compat_resource (>= 12.14.7)
  packagecloud (0.2.5)
  php (2.2.0)
    build-essential (>= 0.0.0)
    iis (>= 0.0.0)
    mysql (>= 6.0.0)
    xml (>= 0.0.0)
    yum-epel (>= 0.0.0)
  poise (2.7.2)
  poise-service (1.4.2)
    poise (~> 2.0)
  runit (3.0.5)
    packagecloud (>= 0.0.0)
    yum-epel (>= 0.0.0)
  seven_zip (2.0.2)
    windows (>= 1.2.2)
  windows (2.1.1)
    ohai (>= 4.0.0)
  xml (3.1.1)
    build-essential (>= 0.0.0)
  yum-epel (2.1.1)
    compat_resource (>= 12.16.3)
  zypper (0.3.0)

在@Tensibai 的评论帖中,他建议在 PHP 包之前安装 nginx。这似乎是解决这个问题的方法。

@Tensibai

I think you should install nginx before php to avoid bringing down a dependency. It sounds like apt brings down the default http server along with php. But that's just a guess