Deploy Ubuntu 14.04 Trusty Tahr Discussion
Great guide. I had a few errors, namely that I needed nodejs installed on the server and that you should get your passenger_ruby path using the passenger-config --ruby-command (at least for RVM).
Hey! How did you solve passenger_ruby path problem? How did you configured passenger_ruby path? I'm stuck with the same problem.
Hi Chris,
I've tried to follow your steps with true care, but for some reason my Nginx is jinxing me :(
I just can't figure out what to do.. just a starting developer alone in the scary world of deployment. Could you maybe help me for a few minutes, for I am sure you are a true pro.
Capistrano seems to be connected, but presents us with an ssh error; permission denied.
There's also a problem with nginx: sudo service nginx restart presents me with FAIL, I've tried
nginx -t, which presents me with a few errors, though sudo nginx -t says everything is fine.
I'm a little lost..
Thanks and it's no problem if you don't want to,
Abel
Great tutorial, Thanks! I had the same issue as @disqus_sRbyuMSsk1:disqus . I also always forget that I need to create the secrets.yml values in production. It would be great to see a section about adding environment variables in the future.
I believe there is a gem that does that for you; however, I find it much simpler just to export the environment variables I need into my shell's rc (.bashrc or .bash_profile if you're using bash) then just refer to them in my database.yml and secrets.yml. Hope this helps.
I have gone through all the process and cap production deploy become successfull, but at visiting my IP address, i am getting message "We're sorry, but something went wrong(500)"
Please suggest me what to do, i have already spend my 3 days to solve it.
Thanks.
Read the Rails and Nginx logs to check for errors. I didn't cover the part of setting up the database.yml and secrets.yml files.
The command:
gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
I had to change to get around firewall problems
gpg --keyserver keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
Had error when I tried to run my app and got error that it could not compile the app, I was missing:
apt-get install libcurl4-openssl-dev
I found this using the passenger tool passenger-install-nginx-module which should be highlighted as a resource.
I had to change following
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
to
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
It was getting blocked by firewall.
Getting following error on `cap production deploy`
```
INFO [75233a5d] Running /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git as deploy@104.236.6.180
DEBUG [75233a5d] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/magnificent/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git )
DEBUG [75233a5d] ERROR: Repository not found.
DEBUG [75233a5d] fatal: Could not read from remote repository.
DEBUG [75233a5d]
DEBUG [75233a5d] Please make sure you have the correct access rights
DEBUG [75233a5d] and the repository exists.
```
Its one of two things:
1- You have not specified your git repository correctly in capistrano's deploy.rb
2- You didn't add your VPS ssh public key to your github key chain for passwordless deployment https://help.github.com/art...
I have just automated the process of setting up a production server for Ruby on Rails production application. It includes Nginx, Redis, Memcached, Ruby with RVM, Unicorn or passenger, Mysql or Postgresql.
It uses Chef, knife solo and librarian. No need to be afraid, they are simple commands for you. Hopefully it can some of you to cut on time they spend for server setup.
Thanks for sharing Shebaz! Part of the reason I don't link to an automated process is because I want people to learn and understand how to setup their machine. It's good to be familiar with all the tools and their configurations. These automated scripts are perfect after you're familiar with the basics! :)
Thank you very much gorails.com I succesfully installed rvm on my ubuntu 14.04. This has been a night mare for me, installing rvm correctly.
I couldn't find a good how to guide on this not until i stumbled upon gorails.com. I now bookmark this site and joined the mailing list so i can also share with others not in this group.
I got these errors when running `cap production deploy`:
DEBUG [7923ef33] Finished in 0.010 seconds with exit status 1 (failed).
/home/deploy/deploy_test/shared/config/database.yml does not exist
I put the rails app here:
/home/deploy/code/deploy_test
Try creating /home/deploy/deploy_test/shared/config/database.yml file on your VPS and fill it with you database configurations.
Adding Capistrano I get error:
Retrying dependency api due to error (2/4): Bundler::HTTPError Network error while fetching https://bundler.rubygems.or...
using rvm. It helps changing Gemfile to:
group :development, :test do
gem 'capistrano', '~> 3.4', require: false
gem 'capistrano-rvm', '~> 0.1', require: false
gem 'capistrano-rails', '~> 1.1', require: false
gem 'capistrano-bundler', '~> 1.1', require: false
end
and execution:
bundle install --full-index
This tutorial worked, but need some addition, especially for installing nodejs on first step and add environment variables on /etc/nginx/nginx.conf.
BTW, thank you very much for pointing in the right direction.
Please can you help me out, I got this error executing "capistrano production deploy":
Alejandros-MacBook-Pro:SAIIP2 Lexynux$ cap production deploy
DEBUG [83f26320] Running /usr/bin/env [ -d ~/.rvm ] as deploy@172.16.79.129
DEBUG [83f26320] Command: [ -d ~/.rvm ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
deploy@172.16.79.129's password:pato2015
DEBUG [83f26320] Finished in 21.796 seconds with exit status 0 (successful).
DEBUG [5d0ab93d] Running ~/.rvm/bin/rvm version as deploy@172.16.79.129
DEBUG [5d0ab93d] Command: ~/.rvm/bin/rvm version
DEBUG [5d0ab93d] rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [5d0ab93d] Finished in 0.155 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [db09357f] Running ~/.rvm/bin/rvm current as deploy@172.16.79.129
DEBUG [db09357f] Command: ~/.rvm/bin/rvm current
DEBUG [db09357f] ruby-2.1.3
DEBUG [db09357f] Finished in 0.160 seconds with exit status 0 (successful).
ruby-2.1.3
DEBUG [8ecded29] Running ~/.rvm/bin/rvm default do ruby --version as deploy@172.16.79.129
DEBUG [8ecded29] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [8ecded29] ruby 2.1.3p242 (2014-09-19 revision 47630) [i686-linux]
DEBUG [8ecded29] Finished in 0.246 seconds with exit status 0 (successful).
ruby 2.1.3p242 (2014-09-19 revision 47630) [i686-linux]
INFO [a5a6ecd3] Running /usr/bin/env mkdir -p /tmp/SAIIP2/ as deploy@172.16.79.129
DEBUG [a5a6ecd3] Command: /usr/bin/env mkdir -p /tmp/SAIIP2/
INFO [a5a6ecd3] Finished in 0.004 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/SAIIP2/git-ssh.sh 0.0%
INFO Uploading /tmp/SAIIP2/git-ssh.sh 100.0%
INFO [8b24e7fb] Running /usr/bin/env chmod +x /tmp/SAIIP2/git-ssh.sh as deploy@172.16.79.129
DEBUG [8b24e7fb] Command: /usr/bin/env chmod +x /tmp/SAIIP2/git-ssh.sh
INFO [8b24e7fb] Finished in 0.004 seconds with exit status 0 (successful).
INFO [58bcdad8] Running /usr/bin/env git ls-remote --heads git@github.com:AlexVentura/SAIIP2.git as deploy@172.16.79.129
DEBUG [58bcdad8] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/SAIIP2/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:AlexVentura/SAIIP2.git )
DEBUG [58bcdad8] Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
DEBUG [58bcdad8] Permission denied (publickey).
DEBUG [58bcdad8] fatal: Could not read from remote repository.
DEBUG [58bcdad8]
DEBUG [58bcdad8] Please make sure you have the correct access rights
DEBUG [58bcdad8] and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@172.16.79.129: git exit status: 128
git stdout: Nothing written
git stderr: Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
git stderr: Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Hey Alejandro,
2 things:
1. You accidentally pasted your password into this (I edited it out), but you'll want to go change that now.
2. It sounds like your SSH key is not added to Github. It's connected to the server and now needs to ask Github for your code so that it can put it on there. That step has failed and so you'll want to make sure that your ssh key is added to your user account on Github.
Please help, I got this error executing "capistrano production deploy":
INFO [77acabf2] Running /usr/bin/env bundle install --path /home/wanglihua/myapp/shared/bundle --without development test --deployment --quiet as wanglihua@123.57.237.245
DEBUG [77acabf2] Command: cd /home/wanglihua/myapp/releases/20150917064532 && /usr/bin/env bundle install --path /home/wanglihua/myapp/shared/bundle --without development test --deployment --quiet
DEBUG [77acabf2] /usr/bin/env: bundle: No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as wanglihua@123.57.237.245: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<sshkit::runner::executeerror: exception="" while="" executing="" as="" wanglihua@123.57.237.245:="" bundle="" exit="" status:="" 127="" bundle="" stdout:="" nothing="" written="" bundle="" stderr:="" usr="" bin="" env:="" bundle:="" no="" such="" file="" or="" directory="">
So I don't need to have the secrets.yml and database.yml files on my rails project? Just the examples?
Thanks awesome tutorial.
Yep! The real reason is so that you don't store your production secrets in git for security.
The Java runtime needs to be noted also. I am stuck here in the deploy stage:
Psych::BadAlias: Cannot load `Rails.application.database_configuration`:
Unknown alias: default
Google results in lots of comments about your default section of your database file. I took those right out and hard coded them vs the alias and I still get this error.