我已经建立了对AWS的弹性青苗一个回报率environement。我能ssh到我的EC2实例。我的主目录是/ home / EC2用户,这是有效空。如果我提出了一个目录,也有说我没有访问的/ home / webapps目录下。
有没有办法在我的豆茎弹性实例运行的耙子命令或导轨控制台?
如果我型导轨控制台我得到Usage: rails new APP_PATH [options]
如果键入RAILS_ENV =产品包EXEC轨控制台,我得到“Could not locate Gemfile
”
对于轨道,为@juanpastas说跳转到/var/app/current
然后运行RAILS_ENV=production bundle exec rails c
不知道为什么,但由于EBS运行一切为根,这个工作对我来说:
sudo su
bundle exec rails c production
这里提到的这些解决方案都没有为我工作,所以我做了,我把脚本/ AWS控制台一个小脚本。
您可以在/ var /应用/当前目录以root身份运行:
eb ssh
cd /var/app/current
sudo script/aws-console
我的脚本可以发现作为Gist here。
其他答案都不为我工作,所以我去寻找 - 这是现在的工作对我来说在弹性魔豆64位Linux的亚马逊2016.03 V2.1.2红宝石2.2(PUMA)堆栈
cd /var/app/current
sudo su
rake rails:update:bin
bundle exec rails console
返回我的预期控制台
Loading production environment (Rails 4.2.6)
irb(main):001:0>
我喜欢创造,在我的Rails应用程序的根目录下有eb_console
文件,然后chmod u+x
它。它包含以下内容:
ssh -t ec2-user@YOUR_EC2_STATION.compute.amazonaws.com 'cd /var/app/current && bin/rails c'
这样一来,我只需要运行:
./eb_console
像我就已经运行heroku run bundle exec rails c
。
这些都不是为我工作,包括AWS控制台脚本。我终于结束了创建在script
一个/var/app/current
目录,然后创建该目录由rails
外形的this answer on another SO question文件。
eb ssh myEnv
cd /var/app/current
sudo mkdir script
sudo vim script/rails
加入这文件并保存:
echo #!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
然后使其可执行文件并运行它:
sudo chmod +x script/rails
sudo script/rails console
和它的工作。
你必须找到你的Gemfile的文件夹:对。
为了做到这一点,我会采取在你的Web服务器配置一看应该是告诉你在哪里你的应用程序目录是一个配置。
也许你知道你的应用程序是。
但如果你不知道,我想给一个尝试:
grep -i your_app_name /etc/apache/*
grep -i your_app_name /etc/apache/sites-enabled/*
要搜索含有your_app_name在Apache的配置文件。
或者,如果你正在使用nginx的,由apache
上述更换nginx
。
之后你会发现应用程序文件夹,进入这个目录并运行RAILS_ENV=production bundle exec rails c
。
确保你的应用程序配置为在生产Apache或nginx的配置运行。