我有一个 AWS Opsworks 设置,我需要在实例启动和应用程序部署时安装 composer,但安装失败。谁能帮我解决这个问题。我正在运行这个厨师食谱:
node[:deploy].each do |app_name, deploy|
script "install_composer" do
interpreter "bash"
user "ubuntu"
cwd "#{deploy[:deploy_to]}/current"
code <<-EOH
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev
EOH
only_if { ::File.exists?("#{deploy[:deploy_to]}/current/composer.json") }
end
end
我收到以下错误(其中第 21 行是带有 script "install_composer" do
的错误)。
[2017-01-18T11:16:38+00:00] ERROR: Running exception handlers
[2017-01-18T11:16:38+00:00] ERROR: Exception handlers complete
[2017-01-18T11:16:38+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2017-01-18T11:16:38+00:00] ERROR: script[install_composer] (composer::install line 21) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20170118-1672-16lyp81" ----
STDOUT: All settings correct for using Composer
The installation directory "/srv/www/[app_name]/releases/20170113140255" is not writable
Could not open input file: composer.phar
STDERR:
---- End output of "bash" "/tmp/chef-script20170118-1672-16lyp81" ----
Ran "bash" "/tmp/chef-script20170118-1672-16lyp81" returned 1
[2017-01-18T11:16:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
我使用这些示例的组合来构建脚本:
https://github.com/awslabs/opsworks-example-cookbooks/blob/master/phpapp/recipes/appsetup.rbhttps://github.com/onema/opsworks-chef-cookbooks/blob/master/composer/recipes/install.rb
安装程序在 Ubuntu 实例上运行。实例报告setup_failed
.如果我禁用自定义配方,实例启动正常。
名称显示在The installation directory "/srv/www/[app_name]/releases/20170113140255" is not writable
中的应用程序是我的应用程序列表中的第 4 个应用程序,但它实际应该在其上安装 composer 的第一个应用程序(它包含 composer.json
)。
希望你能帮助我。谢谢。
当我意识到用户在食谱中应该是"root"而不是"ubuntu"时,我解决了它。ubuntu 用户根本没有足够的权限在发布文件夹中创建新文件夹。