So I am new to deploying to an Ubuntu Server (12.04). I have nginx and unicorn installed. Everything seems to be working except for the fact that I don't know how to point it to my app. Currently I am pointing to 'home/administrator/apps/my_site/current/public' however all my files are in 'home/administrator/apps/my_site/app/views/'. I am currently only pointing to the static files like the error htmls and the default rails index.html. How do I get nginx to point to my views/app?
Thanks.
If you're using Nginx + Unicorn then you don't point Nginx at any path, you run up unicorn on the server and then have Nginx proxy all it's requests to the unicorn instance. I would recommend looking at using foreman and then it's foreman export upstart which exports ubuntu upstart scripts for controlling unicorn.
This link gives you details on how to config your nginx site.
Related
I am using nginx with Phusion Passenger to bootload a ruby on rails application, if I run the application like
rails s -e production
It does connect correctly to the database, but when bootloaded from nginx with passenger it tries to use root to the database, like ignoring the config files.
I already tried giving permissions, but doesnt look like there is the problem, I already opened the 3 possible host names for root, which could be "localhost", "%" and "127.0.0.1", but in any case it should be openning a connection with root
I would say something is weird on how passenger behaves or that somewhere (not in the app) is ignoring the database.yml or overriding the credentials
in my opinion, I think you should try Passenger Standalone that is what I use and it works fine.
It it possible to setup Passenger to use a PassengerMaxRequests on Heroku? From what I can tell, Heroku requires the passenger configuration to happen within a Procfile like so:
web: bundle exec passenger start -p $PORT --max-pool-size 4
I tried --max-requests but get an invalid option exception. It also doesn't appear under heroku start --help. Any way to get this parameter (or any of the other parameters from the docs) working with a Procfile?
It looks like you should follow the Passenger Standalone Advanced Configuration guide, and create an nginx config file (not apache), since it seems the standalone passenger actually just comes with nginx.
passenger start --nginx-config-template nginx.conf.erb
And then you should be able to set passenger_max_requests
I use a Windows machine and have a Django project that I have successfully deployed to Heroku, albeit using the development server. To use a production server Heroku seems to require 'Gunicorn' which does not run on Windows.
This is not good for testing locally before deploying. Does anyone know of any way to get around this? Perhaps some way to use a different server on Heroku?
I found a solution that may help when deploying to heroku using a Windows machine. Here is what I do:
Use the development server locally with:
python manage.py runserver
Install and add 'Gunicorn' to your installed apps in settings.py.
Add a process file in the root directory that tells heroku to use the Gunicorn server. This is a file called 'Procfile' with the following code:
web: python kalail/manage.py run_gunicorn --bind=0.0.0.0:$PORT
This way you test using the development server, while heroku uses the Gunicorn server. Make sure you set up serving static files(css/js/imgs) after this, because only the development server automatically serves static files, and the Gunicorn server will need to be configured to do so.
You can run the development server locally quite easily:
> python manage.py runserver
All you need to do is specify path to wsgi script from root directory:
$web: gunicorn hellodjango.wsgi
I came across this behavior and was wondering if anyone else had seen it. I have a workaround so it's not a show-stopper.
I created a new app on Heroku with a Cedar stack. When demonstrating multiple environments I added the following config var:
heroku config:add RACK_ENV=staging --app appname
I visually verified that the environment var was set, then put the following route in my simple Sinatra example:
get '/?' do
ENV['RACK_ENV']
end
When I tested locally on my laptop, I received the expected development.
When I pushed to Heroku and hit the same route on herokuapp.com I got development instead of staging.
I switched the web server from Thin to Unicorn through the Procfile and pushed the changes back up to Heroku.
Now when I hit the route, I get the expected staging.
Has anyone else seen this? My workaround on another project where I was running Thin was to key the environment off of the New Relic app name. (I didn't switch to Unicorn because I need New Relic to work and currently Cedar and New Relic and Unicorn work together).
I had the same problem with sinatra and thin on the cedar stack using heroku's example sinatra app. The RACK_ENV refuses to be set to anything but development. (Heroku seems to think that it's RACK_ENV is set, since running 'heroku config' displays the environment you set, however in the app it's always development).
The same app on the bamboo stack had no problems.
EDIT: I submitted a ticket to heroku about this and got a really quick response which fixed the bug for me:
QUOTE:
It looks like there's a small bug in our default Procfile if you're using thin. Can you create a Procfile with the following in it?
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
You can also set both your RACK_ENV and RAILS_ENV to staging using the Heroku gem ... then it works as expected. I think it may be a problem with Heroku.
I have a Rails 2 application running well on my local machine at the moment. But fails on Heroku, here's the log: http://pastie.org/1957572
I can't figure out why the path is "app/app/model/.." instead of just "app/model...", is there anything I need to config my Rails app for Heroku?
Thanks!
You probably figured this out, but it's because /app is the root folder for apps on Heroku
It's like if you had it on your own VPS and it was in /var/www, then the error would read like "/var/www/app..."