I'm working on deploying my rails app using apache and passenger on a virtual server that I'm managing via Virtualmin. All of this is being hosted on an Ubuntu 12.04 VPS.
Anyway, I'm getting the following error.
Forbidden
You don't have permission to access / on this server.
At first, when this occurred, I was getting the error:
Premature end of script headers
in my virtual host error log and a key error in my apache error log. Both of these went away though once I updated my config/secrets.yml file. The 403 error, however has remained. Additionally, the virtual server error log had the error:
Directory index forbidden by Options directive
Additionally I've made sure that my public_html directory (and all of is subdirectories) is the right user for apache. I've checked the production error log, and apache error log and haven't seen anything come out when I load the page.
Any ideas as to what I should try?
Many thanks in advance
Related
I'm attempting to host my rails app on a vps. The issue that I'm running into is when I try to navigate to my rails app, I get the following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
When I check out the virtual server's error log it tells me the following:
Premature end of script headers:
And sometimes that's followed with a feed or a contact or a referer: myurl.com/ or nothing at all.
I've seen plenty of posts regarding this error messages elsewhere but none so far have resolved the matter. The general consensus seems to be that it likely has to do with the rails environment variable or file.
As this is my first attempt at putting a rails app on a production server, I figure this is plausible. Below is my environment.rb
cat config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
As for the server, I'm using Ubuntu 12.04 with Webmin/Virtualmin and apache2 with passenger. Ruby 2.1.5p273 was installed using RVM and all gems are up to date.
Any thoughts would be helpful!
Today I was confronted with exactly the same problem. In my case it was the line 'secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>' in config/secrets.yml (but the env variable was not defined on the server). Please, look in ยง3.3 of http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html.
I installed a Rails app on the DigitalOcean server, but instead of seeing the app itself, there's the error 500 page.
When I check the directory "logs", there are no data written in the production.log file, or in the unicorn.log.
So, how can I find out what's wrong?
You could try look for nginx's logs in:
/var/log/nginx
usually are placed there:
access.log and error.log
I have my app in production mode in my linode account and I get in one page a 500 internal server error the message:
We're sorry, but something went wrong.
However in my development environment works fine this page.
How can I debug this error?
How can I see the error origin in my production mode?
I want that rails show errors in production mode.
How can I do it?
Thank you!
If you have access to ssh, log in to your server via ssh and go to your rails log directory, which is inside your rails directory.
Once you are there run the command tail production.log . If this doesn't give you enough information you can also do a tail -n100 production.log (gives you last hundred lines of the production log).
If you have deployed via heroku, then you can access the logs by running heroku logs in your local console. (more information here https://devcenter.heroku.com/articles/logging)
I also find it helpful to use the exception_notification gem https://github.com/rails/exception_notification when running in production, as it emails you a stacktrace when an error occurs. Plenty of others also use Hoptoad (http://hoptoadapp.com/) or Exceptional (http://www.exceptional.io/) however i prefer the simple exception_notification gem.
Also, in some rare occasions when i can't trace the error as a final measure i sometimes open up port 3000 temporarily on the remote server firewall and cd to the rails project and run rails server production with the log level set to debug in config/environments/production.rb so i can see the error in the console, and then close off the port when i have finished.
Hope that helps.
tail -n100 production.log
will only show the last 100 lines of the log file. Just in case you want to see the log running in real time.
use this
tail -1000f log/production.log
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
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