Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy Ubuntu 14.04 Trusty Tahr Discussion

Chris Oliver asked in General

Awesome tutorial Chris Oliver very detailed and well explained. I managed to get the server up and running. However, I have one hiccup, after I run cap production deploy some of my assets do not show up. Some images appear, others don't and when viewing the webpage on mobile it seems the css doesn't work as well ( showing the desktop site when view from mobile ). Any idea why this may be so?

The following are two logs that appear in red when cap production deploy is run:

[4ccfb05d] I, [2015-10-03T15:44:57.443886 #8238] INFO -- : Writing /home/deploy/test_deploy/releases/20151003194438/public/assets/lead-f711de8905ea0fb3d7e8f652cf53a1a9f36e231231a122bd165693d992487d65.png

[4ccfb05d] cp -p /home/deploy/test_deploy/releases/20151003194438/public/assets/ckeditor/plugins/icons_hidpi-cdeb694f528f1dce0ef080b7473dfe9283d8b625f7311db7baea4eb9e7368207.png /home/deploy/test_deploy/releases/20151003194438/public/assets/ckeditor/plugins/icons_hidpi.png

Reply

The one thing I might think of is that you want to make sure you're using ERb asset_url helper appropriately to reference your images. If you're using those through CSS, you can use the "asset-url" helper in your CSS. The urls that are used in production have different URLs than in development so you have to use these helpers.

Reply

Hello,

Please help urgent, I'm currently using mysql2 as the adapter. When i try run "rails generate scaffold User email", I get the error -

/home/deploy/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/application/configuration.rb:110:in `database_configuration': Cannot load `Rails.application.database_configuration`: (RuntimeError)
Could not load database configuration. No such file - ["config/database.yml"]

I have already configured my database.yml as

production:
adapter: mysql2
database: deploy_test
username: deploy
password: password

Reply

Hi there,
Soiunds like you are trying to continue development using your production server. You will want to continue development on your local machine, checking the files into version control and deploying when needed. Hope this helps!

Reply

You mention that Capfile should include `require 'capistrano/rails'`. However the base cap installation has commented out ` # require 'capistrano/rails/assets' # require 'capistrano/rails/migrations' ` What is the delta between these two options?

Reply

It actually includes bundler, assets, and migrations in one. https://github.com/capistra...

Reply

Thanks for the guide, very useful! I have "thin" gem installed in my gem file. So, the nginx is connect thin or Passenger? Do I need any config for better performance?

Reply

In production I typically use Passenger because it has really great performance. You can also use thin but you'll have to set it up differently than I've laid out here. Check out some things like this: http://www.rackspace.com/kn...

Reply

HI , i try to deploy by following your tutorial but every time i run i saw this in in server
nginx error file

[ 2015-10-18 20:48:51.3464 3671/7f4021bf3700 age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 91421a8b. Please see earlier logs for details about the error.

[ 2015-10-18 20:48:51.3469 3671/7f4021bf3700 age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-2] Cannot checkout session because a spawning error occurred. The identifier of the error is 91421a8b. Please see earlier logs for details about the error.

tanvir@tanvir:~$

Reply
Howard Cornett Howard Cornett

This has been a great help, but I am totally stuck now. Every time I manually create the database on the server as you suggest, it is created successfully. However, when I try to connect to it with my deploy user, it tells me the database does not exist. But if I login as the postgres user, it is there. What am I doing wrong, and how can I fix it?

Reply
Howard Cornett Howard Cornett

I think I figured out my own solution. The process you listed for created the database didn't work for me. So from the deploy user account on my remote server I entered the command:

psql -d postgres -W

That logged me into psql as the postgres user. I then created the database as you instructed from there. Then I was able to log into the database successfully from my deploy account.

Reply
Fritz Rodriguez Jr. Fritz Rodriguez Jr.

Hey Chris,

Anyway I could get a link to download this video, would be helpful for easy reference. Thanks so much!

Best!

Reply

There's a cool little trick that if you change the youtube URL from "youtube.com" to "ssyoutube.com" it will redirect and give you a link to download the video like this:

http://en.savefrom.net/#url...

Reply
Fritz Rodriguez Jr. Fritz Rodriguez Jr.

Sweet...thanks Chris!:) FYI creating my second droplet on Digital Ocean. Going to see how difficulty it will be to manage my own servers...two reasons 1. Cost (cheaper and faster with SSD) 2. With you instructions, it seems easier to get something up and running and I get more granular control over the environment...been having issues with other hosting services. Security is the one major area of concern going forward. Also, is there a good service or app for monitoring (like when the app goes down)?

Reply

For security, there's a few things you can do like setup a firewall and only open port 80 or 443 for web, setup fail2ban, and disable password authentication over SSH. You'll want to be careful not to lock yourself out of the server, but the recovery console can still let you in if you do. :) More stuff to checkout https://wiki.ubuntu.com/Bas...

Pingdom is probably the most used one, but there are a bunch if you search for monitoring. I use Pingdom's free service I think.

Reply

this is an incredibly huge pain point for us ... thanks for video (pray you keep updating it)

Reply

10+ thx!

Reply

This is a fantastic article that I have used to deploy over 5 applications! Thanks so much for iwriting it!!
I find that the postgres createuser command is a bit old and since postgres no longer prompts for options by default.. I find it works better with

createuser --interactive --pwprompt

,

Reply

Be great to see a tab for installing ruby using ruby-install and chruby, and an update to the nginx section showing how to set passenger_ruby when using chruby.

ruby-install and chruby makes installing ruby and switching between versions so easy even I could do it!

Reply

Hello I am trying to install Fedena School ERP using Nginx and Capistrano. I have managed to get Nginx running but now I am completely confused, I really don't know where to go from here; the entire Capistrano process makes me confused. Also, I already have my app folder locally and not on git.
Please I need help on this please.

Reply

Hey! Thanks for detailed guide. However, I'm stuck with a problem while setting up a server using rvm method.


App 25994 stdout:

App 25994 stderr: *** ERROR ***: Cannot execute /home/deploy/.rvm/wrappers/ruby/ruby-2.1.5@gemset_name/ruby: No such file or directory (2)

: Could not spawn process for application /home/deploy/india_boulevard/current: An error occurred while starting up the preloader. It exited before signalling successful startup back to Phusion Passenger.

I tried changing following line, but no luck so far :(


passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.1.2/ruby;

EDIT: Thanks to Stephen Dolan's comment I solved the problem like this http://stackoverflow.com/a/...

Reply

Hello! Any reason you didn't place capistrano related gems into the development group?

Reply

In "Installing Nginx" section, why do you have the same apt-key and apt-get commands repeated twice?

Reply
Jaime Bellmyer Jaime Bellmyer

I was getting the following error upon deploy:

rbenv: version `2.1.2' is not installed (set by RBENV_VERSION environment variable)

I found this fix, which worked for me:

set :rbenv_path, '/home/deploy/.rbenv/'

The source said to add it to deploy.rb or it wouldn't work. Sure enough, you can't add it to the Capfile like the other rbenv settings. Not sure why. I'm posting in case it helps others, and for the next time I read this article to setup a server :)

Reply
Magzhan Shokparbayev Magzhan Shokparbayev

It helped. Thanks. It should be placed in config/deploy.rb file:

set :rbenv_path, '/home/deploy/.rbenv'

Reply
Jaime Bellmyer Jaime Bellmyer

I also had these issues:

error (upon cap production deploy): Could not find a JavaScript runtime

fix (on the server command line): sudo apt-get install nodejs
----
Postgres only allowed connections from the postgres system user, so:
sudo su postgres
psql -U postgres -h localhost
(in psql): alter user postgres with password 'yourpasswordhere'

Reply

I bought Passenger's enterprise license, It tell me "uninstall it by removing the directory in which you extracted Phusion Passenger". Could you tell me which directory should I remove? Thanks!

Reply

I think you can just run "sudo apt-get remove passenger" for that.

Reply
CM7Qp6crGEGQDfH6s CM7Qp6crGEGQDfH6s

Thanks Chris for this informative tutorial. Two questions here. What should I do if I don't want to use github or bitbucket etc? I just want to develop locally and upload to the server using ssh, ftp etc. Another question is that is it possible to deploy multiple Rails apps in a single VPS in the configuration described in your tutorial? Thanks.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,584+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.