I finally completed my own app, so the only work left is deploying the app.

I'm using Ubuntu 10.04 and apache2(installed by apt-get), so I'm trying to deploy through passenger.

I installed passenger gem like this:

sudo gem install passenger
rvmsudo passenger-install-apache2-module

and I configured apache settings as what the installation message says.

I added below lines in the middle of /etc/apache2/apache2.conf file.

LoadModule passenger_module /home/admin/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/admin/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/admin/.rvm/wrappers/ruby-1.9.3-p194/ruby

and, I appended below lines in /etc/apache2/sites-available/default file.

<VirtualHost *:80>
  ServerName localhost
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/admin/homepage/public
  <Directory /home/admin/homepage/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews

But when I restart the apache service and hit the address, 500 error occurs.

At first, it was same 500 error but the 500 error page is from apache's, but when I reinstalled the libapache2-module-passenger, the 500 error page is changed to that from rails'.

Because of rails' 500 error page(which is located at public/500.html), I think passenger module is properly connected with apache.

What should I do to fix this problem?

Do I need to configure something inside my app before deployment?

migrated from stackoverflow.com Sep 2 '12 at 19:56

This question came from our site for professional and enthusiast programmers.

  • What is the actual error you're getting (the error in the logs...). That will tell you exactly what's going wrong, the info you provided (config) is helpful but the error message is crucial to understanding/fixing the problem. Judging from what you've posted above, my guess is that permissions may be an issue. Your code is in the 'admin' home directory and depending on your permissions this may not be readable by the user that apache is using. The apache user might be apache or www or something similar. You should move your code to a dir outside of home (maybe /data or /var/www) and set .. – Charles Addis Sep 18 '17 at 7:20
  • ... the correct permissions. All the directories/files in your app should be readable (and executable or writable if needed) by the effective UID running your web server. It doesn't sound like you have much linux knowledge, so I won't get into different ways of doing this other than just changing the file mode (chmod). Other things that may cause permissions are access controll lists (if you have the acl package) or selinux policies (if you are using selinux). – Charles Addis Sep 18 '17 at 7:23
  • Edit: Just saw this is a super old post somebody bumped... – Charles Addis Sep 18 '17 at 7:26

You need to configure database connection and install all necessary gems (bundle install). Check out what logs are telling about your problem, you can find it in log/ dir in a root path of your application.

Do you run it in production mode?
You need to define development mode in your apache config otherwise it will be production mode.

  • Yes, I think it's running in production mode. production.log file exists and the recent logs are in that file. The most recent log is this: Connecting to database specified by database.yml Started GET "/" for 147.xxx.xxx.xxx at 2012-08-30 16:51:04 +0900 Processing by StaticPagesController#home as HTML Rendered static_pages/home.html.erb within layouts/application (29.0ms) Completed 500 Internal Server Error in 62ms ActionView::Template::Error (logo.png isn't precompiled) app/views/static_pages/home.html.erb:8:in `_app_views_static_pages_home_html_erb__2032549551898309484_28916320' – user1633983 Aug 30 '12 at 7:54
  • Wow, after inspecting the log file, I googled with keyword "isn't precompiled", and I modified config/environments/production.rb file's "config.assets.compile = false" to true. It works but I'm not sure is it OK to let that configuration be true. – user1633983 Aug 30 '12 at 7:59
  • I realized that I need to precompile assets before deploy. For newbies , just like me, who will read this article later, I tried in this way: in config/environments/production.rb, I uncommented "config.assets.precompile" line and added css/js files I want to precompile. and let "config.assets.compile" be false.(Googling tells me that letting that line be true is not recommended.) and execute the command "RAILS_ENV=production RAILS_GROUPS=assets rake assets:clean tmp:clear assets:precompile && touch tmp/restart.txt". And it seems to work well. – user1633983 Aug 30 '12 at 8:16
  • 1
    @user1633983 if you think, that your solution will help future users, please post your comments as an answer to this question – oers Aug 30 '12 at 12:01


RailsEnv development


RailsEnv production

to vhost

then restart.

Your Answer

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