Apache/Rails/Passenger Displaying Site Index? - ruby-on-rails

I have a Rails app that I have successfully tested with Mongrel and Webkit. Now I want to test deployment. I set up a VMWare Image using Ubuntu 8.04. I have installed Rails following this method https://help.ubuntu.com/community/RubyOnRails with the exception of using Gems 1.3 instead of 1.2. I have configured and installed Passenger. However, when I visit my sites index (http://some.ip.that.i'm.testing/) I simply get the directory index of my rails site. I should note that since I'm testing I just dumped my app in /var/www.
My Apache2 error.log file shows this and this only:
[Tue Sep 30 15:10:41 2008] [notice] Apache/2.2.8 (Ubuntu) Phusion_Passenger/2.0.3 configured -- resuming normal operations
Any idea what could be causing this problem? It seems Passenger is configured properly, but I'm not sure why my rails app is not displaying and why the site's directory listing is.
Thanks.

Two questions:
1) Is Rails running at all on the server? Passenger should start Rails automatically on first request - if you do a ps, do you see it running?
2) Which directory are you seeing - is it your rails directory or the public/ directory? If it's the former, your symlink is likely pointing the wrong place (it should go to public/).
(I've seen this problem before and am trying to remember how I debugged it... these are my first two thoughts.)

Related

Rails server claims "No such file - ["config/database.yml"]" even though it is there

After developing in Rails on a virtual Linux machine, I just recently installed Windows Subsystem for Linux. Before the Christmas weekend, it was working just fine, but as of this morning, when I try and start up my rails server, it gives me the following complaint:
Could not load database configuration. No such file - ["config/database.yml"]
Of course, when I go into my config folder, database.yml is there - just like it was last week. So I'm confused why it can't find the file now when it absolutely could find it before. Is this some sort of WSL quirk that makes the file hard to find for some reason?
This is most likely guesswork, but I assume that there is a permission issue. If config/database.yml has insufficient ownership or read-levels, it may not be found by your Rails application.
For further diagnose, I recommend posting the output of:
# Get permission details for your config
ls -laZ config/database.yml
And maybe some details of which user is starting the Rails application (effectively which user owns the Ruby process).

Rails 2.3 pages are cached when they shouldn't on Passenger 5

We recently migrated an older Rails 2.3 website from a CentOS 6 server to CentOS 7 server. Since that transition, a few pages are getting cached that shouldn't be.
Here are the details on the web server changes:
The old system was Passenger 4.x, the new is Passenger 5.0.30.
The old system was Apache, the new is Nginx 1.10.1
The app has not been changed, other than adding the config.ru for Passenger 5
We are running Rails 2.3.17 on Ruby REE
We are running Memcached for some fragment caching, but not with these pages.
Things we have tried:
If we modify the view, the changes do not show up until restart. The view template is cached.
We disabled Passenger 5's turbocache. It did not help.
We removed all keys from Memcached. It did not help.
Find and delete on disk Rails caches – we didn't find any (and shouldn't).
More details:
We host several other Rails 2.3 websites and dozens of Rails 3.x/4.x sites and do not have this issue.
If you restart Nginx or touch tmp/restart.txt the changes show up.
The log files for Nginx show a 200
The production Rails log file shows times for db and view creation.
It looks like it is generating the output, but then it pulls from some kind of cache between Rails, Passenger and Nginx.
What could be causing this?
This turned out to be a scope that was calling DateTime.now that was not wrapped in a proc - Proc.new { DateTime.now }.call. This causes the date to be cached along with the model.
Why it didn't cache under the old setup, I'm not sure. Maybe it just restarted more often so we never saw it.

rails app - sudden 403 after pull - how do I start to debug?

I'm been working on a rails 3.1 app with one other dev.
I've just pulled some of his recent changes, using git. And am now getting a 403 on any page I try to visit.
You don't have permission to access / on this server.
I'm running the site locally through passenger.
Oddly, when I start the app using rails' internal server. I can visit the site at http://0.0.0.0:3000
Looking at the changes in this recent pull, the only files have changed are some javascripts, some html the application.rb, routes.rb and a rake file.
How do I debug this, I'm a bit lost on where to start?
EDIT:
If I roll back to an earlier version the site works, through passenger. Which leads me to believe the problem is within the rails app, rather than an Apache error. Or it could be a permissions thing, can git change file permissions in this way?
IMHO this is a configuration error in Apache or wrong directory layouts. Make sure that the passenger_base_uri still points to the public folder inside your rails project and that there are no hidden .htaccess files which block access. Also verify that your sym-links are correct (if there are any). Also check your Apache error log.
Start by launching your console to see if rails and your app can be loaded.
In your application root directory type :
rails console

My Rails app is returning HTTP 500 for all its URLs, but nothing shows up in the log file. How can I diagnose the problem?

I have a Rails app that is running on a production server with Apache and Phusion Passenger. The app works fine locally when using Mongrel, but whenever I try to load a URL on the production server, it returns HTTP 500. I know the server is working properly, because I can get the static elements of the application (e.g., JavaScript files, stylesheets, images) just fine. I've also checked the Passenger status and it is loading the app (it must be, since the app's 500 Internal Server Error page is returned, not just the default Apache one). Also, when I load the app via script/console production and do something like app.get("/"), 500 is also returned.
The problem is that there is nothing in the log files to indicate the problem. production.log is empty. The Apache error logs show no problems with Apache, either. I'm stumped as to what's going on and I'm not sure how to diagnose the problem.
I know I may have been a bit vague, but can anyone give a suggestion on what the problem may be? Or at least a way I can go about diagnosing it?
The answer for this specific situation was a problem with my app. One of the model classes used a different database connection than the rest of the app. This database connection was not configured properly. I think the reason why nothing was written to the log files is that Rails bailed out without having any idea what to do.
Since it may be helpful for others to see how I diagnosed this problem, here was my thought process:
The issue couldn't be with Apache: no errors were written into the Apache log files.
The issue probably wasn't with Passenger: Passenger wasn't writing any errors to the Apache log file, and it seemed to be loading my app properly, since passenger-status showed it as loaded and it was display my app's 500 Internal Server Error page (not the default Apache one).
From there I surmised that it must be something broken in my app that happened very early on in the initialization phase, but wasn't something that caused the app to completely bail and throw an exception. I poked around in the Phusion Passenger Google Group, and ultimately stumbled upon this helpful post, which suggested that the error may be a database connectivity issue. Sure enough, removing this misconfigured database and all references to it made the app work!
Have you tried running the app locally using Passenger?
Try running the application locally on Mongrel in Production mode, to make sure that there's no weird issues with that particular environment. If that works, then you know that it's not an issue with your codebase. Since your static components are being served properly, that tells me that Apache is working fine. The only gear in the system left is Passenger. At this point, I would say it's an improperly configured Passenger. You should post up your Passenger config file, and ask the question on ServerFault.
A couple of things to try :
Have you gone though the following from the docs:
6.3.7. My Rails application’s log file is not being written to
There are a couple things that you
should be aware of:
By default, Phusion Passenger runs Rails applications in production
mode, so please be sure to check
production.log instead of
development.log. See RailsEnv for
configuration.
*
By default, Phusion Passenger runs Rails applications as the owner
of environment.rb. So the log file can
only be written to if that user has
write permission to the log file.
Please chmod or chown your log file
accordingly.
See User switching (security) for details.
If you’re using a RedHat-derived Linux
distribution (such as Fedora or
CentOS) then it is possible that
SELinux is interfering. RedHat’s
SELinux policy only allows Apache to
read/write directories that have the
httpd_sys_content_t security context.
Please run the following command to
give your Rails application folder
that context:
Have you checked your vhost or httpf.conf file ? Do you have any logging directives ?
Check the top level apache log file
Try setting PassengerLogLevel to 1 or 2 or 3, as shown here http://www.modrails.com/documentation/Users%20guide.html#_passengerloglevel_lt_integer_gt
Do you have any rack apps installed ?
My suggestion would be to go right back to "Hello World" land and create the smallest possible Ruby example application and upload it to see if there is a problem with Passenger or Ruby on the server.
May be a silly suggestion but I suggest you start by increasing the logging levels on production while you are testing. Do this in config/environments/production.rb and use:
config.log_level = :debug
This should at least get you some sort of backtrace so you can start to find the problem.
If you still get nothing - you may find that you have an issue with something as simple as a missing gem/plugin on your production server. That sort of thing may well manifest as a "500" error and just not be very verbose for you.
Can you run the test suite on your production server?

Having problems deploying a Rails app to Fedora 8 w/Passenger

I'm using Capistrano and have everything configured. The weird issue I have is that before, I got a nice Passenger error saying what was wrong (I hadn't fully uploaded my vendor/rails directory). After I do that, however, I'm now getting the general Rails We're sorry, but something went wrong 500 error instead of the Passenger error page. My production log shows nothing (only that the log was created). Apache logs show nothing. I don't get why I'm no longer seeing the Passenger error that tells me exactly what is wrong; fixing the error Passenger was complaining about shouldn't prevent it from getting there, should it?
Can anyone help me?
FYI I'm running several PHP-based applications on the same server, with the rails app set as a subdomain (e.g. railsapp.mydomain.com). The full stack is:
Fedora Core 8
Apache 2.2.9
MySQL 5.0.45
Rails 2.3.4
Passenger 2.2.5
You have two issues at hand:
You're log file isn't writable by Passenger. Passengers runs as Apache. So make sure the webserver has the correct rights to write to the log/ directory.
You are probably missing a gem, database or configuration file. Can you start a console session?
./script/console production

Resources