Nginx: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
Line 19: Line 19:
</pre>
</pre>


== Secret Key for Production ==
== Transition to Production ==
 
=== Secret Key ===
Not needed for development, but needed for production.
Not needed for development, but needed for production.
* run <code>rake secret</code> to create a giant random number  
* run <code>rake secret</code> to create a giant random number  
Line 27: Line 29:
</pre>
</pre>
* run "<code>chmod 600 /etc/default/nginx</code>" to keep the secret secret.
* run "<code>chmod 600 /etc/default/nginx</code>" to keep the secret secret.
=== Compile Assets ===
You will need to manually compile your assets before going into production:
<pre>
rake assets:precompile
</pre>


== Old Info ==
== Old Info ==

Revision as of 18:49, 17 October 2014

Current Info

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html

Restart Rails app in Passenger

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#_redeploying_restarting_the_ruby_on_rails_application

touch /webapps/mycook/tmp/restart.txt

Passenger will automatically restart the application during the next request.

Useful Passenger Tools

passenger-status
passenger-memory-stats

Transition to Production

Secret Key

Not needed for development, but needed for production.

  • run rake secret to create a giant random number
  • add this line to /etc/default/nginx:
export SECRET_KEY_BASE=bcd25705f5c39e...
  • run "chmod 600 /etc/default/nginx" to keep the secret secret.

Compile Assets

You will need to manually compile your assets before going into production:

rake assets:precompile


Old Info

http://excid3.com/blog/setting-up-ubuntu-12-04-with-ruby-1-9-3-nginx-passenger-and-postgresql-or-mysql/

Install Nginx with Passenger

Since we’ll be using Nginx for serving our application, we’re going to install it using the Passenger installer. Nginx modules need to be compiled into nginx, unlike Apache, so we can’t just install the package from the PPA.

sudo gem install passenger
sudo passenger-install-nginx-module
# Choose "download, compile, and install Nginx for me"
# Accept defaults for any other questions it asks you

Upgrading Nginx

sudo gem update passenger
sudo passenger-install-nginx-module
# go ahead and install latest nginx with ruby support

This will overwrite existing files in place. Then you will need to update the "passenger_root" directive in nginx.conf to point to the latest passenger gem.

Confirm server version with this:

/opt/nginx/sbin/nginx -v