EC2 - cannot deploy as “bitnami” user

泄露秘密 提交于 2019-12-11 04:46:11

问题


I am using Capistrano for deploying a Rails app to Amazon EC2. In the deploy files, I have following credentials for connecting to Amazon EC2:

set :user, "bitnami"
#set :user, "root"
server "ec2-XX-XXX-XXX-XX.compute-1.amazonaws.com", :app, :web, :db, :primary => true
ssh_options[:keys] = ["/Users/ada/my_amazon_ec2.pem"]

When I run cap deploy:setup and cap deploy:check, I get following:

The following dependencies failed. Please check them and try again:
--> You do not have permissions to write to `/www/myapp'. (ec2-XX-XXX-XXX-XX.compute-1.amazonaws.com)
--> You do not have permissions to write to `/www/myapp/releases'. (ec2-XX-XXX-XXX-XX.compute-1.amazonaws.com)

How's that possible? I am able to connect via SSH to EC2 as the user bitnami, but when I try it as the user root, I get the message that I should use the bitnami user for login and the connection is closed.

If I try to change in the deploy files change the bitnami user for root, the whole deployment process is ok, but then when I log in through SSH (as the bitnami user) to EC2, I don't see any files that should be deployed, the final directory is just empty.

What is wrong in this case?

Thank you so much


回答1:


sudo chown -R <user> <folder path>

did the trick. The user was not the owner of the folder and hence cap check was throwing error.




回答2:


Do you have the /www/myapp directory already created and does bitnami user have writing permissions there?

Let's assume your application is called "myapp123" and you want to deploy it to /opt/bitnami/apps/myapp123.

Create application directory and set proper permissions:

mkdir -p /opt/bitnami/apps/myapp123
chown -R bitnami /opt/bitnami/apps/myapp123

Add the following options to your deployment config file:

set :application, "myapp123"
set :deploy_to, "/opt/bitnami/apps/#{application}"

Are you going to use Phussion Passenger? In this case you will also need to add the following to the Capistrano config:

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

Which BitNami AMI do you use?




回答3:


Bitnami stacks usually have default webroot at

/opt/bitnami/apache2/htdocs

Try writing to that folder instead (using bitnami user).

If you would like to change the webroot to another directory, you will need to create the directory and set the proper permissions, as well as tell apache you've changed the web root (click for more on how to do that).

If you are having trouble creating the directory, or applying permissions, prefix your commands with sudo like sudo mkdir www.




回答4:


Do you have this:

ssh_options[:auth_methods] = ["publickey"]


来源:https://stackoverflow.com/questions/16339761/ec2-cannot-deploy-as-bitnami-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!