I'm attempting to deploy a small rails app w/ sqlite3 to a micro AWS EC2 CentOS 6 instance using capistrano (after not having much success with nginx & passenger). I follow this site to deploy my app


and the deploy is a success but the AWS instance DNS is responding with page isn’t working and ERR_EMPTY_RESPONSE. What's weird is when I navigate to my DNS the console says Navigated to data:text/html,chromewebdata which is not right. I tried Googling the problem but not many had similar problems. It's difficult to track this when the deployer was a success when I ran bundle exec cap production deploy from my mac (not inside AWS server) and there were no errors. Does anyone have a similar problem and know a fix for this silent deployment problem?

I deployed the app as a deployer user at /var/www/texter/ path and the user has access to this folder inside the AWS ec2 instance.

Port 80 and 8080 are open in my AWS security group setting so I don't think that's a problem either. I tell my firewall to accept the port 8080 and 80 with this command (correct me if I'm wrong) below but that didn't do anything.

sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Here is what I did to set up the server as a deployer user, which is standard for a rails app:

sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

# preparring rbenv, ruby, rails, nodejs
git clone git://github.com/sstephenson/rbenv.git .rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

exec $SHELL
rbenv install -v 2.1.0
rbenv global 2.1.0
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install rails -v 4.2.6 -V
rbenv rehash
sudo yum -y install epel-release
sudo yum install nodejs

after that I set up my rails with capistrano with these content in the config/deploy.rb, Capfile, /config/deploy/production.rb (all of them are same as the tutorial link I posted above but posting for reference).

inside config/deploy.rb

set :application, "texter"
set :repo_url, "my_github_repo"
set :linked_dirs, %w(
  bin log vendor/bundle public/system
  tmp/pids tmp/cache tmp/sockets
set :puma_bind, "tcp://"


# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Include tasks from other gems included in your Gemfile
# For documentation on these, see for example:
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require "capistrano/puma"
# require 'capistrano/passenger'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

for my content in /config/deploy/production.rb:

       :user => "deployer",
       :roles => %w(web app db)

I resolved with some help from this page

Can not access EC2 server via IP address

Option #2 solved my problem and hope it will help some others. A different problem popped up though. I got the server running in the public IP but puma is not running; the deployment message claims everything was working fine. I resolved by bypassing this and run bundle exec passenger start inside the /var/www/myappName/current path as root and that kickstarted nginx engine to proxy the localhost server. Resolving puma server is a completely different problem which I might ask in another post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.