

# You can check available worker numbers with $ grep -c processor /proc/cpuinfoĪpp_dir = File.expand_path("./.", _FILE_) In common create file config/puma.rb, copy codes below and modify as you like: There are several ways to start puma server, two ways are recommended below: Proxy_pass proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for Server_name localhost # or your server name Server unix:/var/www/my_app/shared/sockets/puma.sock # Path to Puma SOCK file, as defined previously Worker_processes 1 # this may connect with the worker numbers puma can use.

Then create a new nf file with your favorite editor, copy codes below and modify as you like: $ mkdir -p shared/pids shared/sockets shared/log Under your app folder, create sockets, pid and log folder with
#New rails postgres app install#
Then add puma gem in the Gemfile and install with Start by copying your app to /var/www/my_app. While reverse proxy server would acts as a load balancer that routes all external requests to a pool of web apps.įor a webserver it is better to use a server user and group, check Users and groups#Example adding a user, below use rails as user name and server as group name, also my_app as rails app name. It was designed to be the go-to server for Rubinius, but also works well with JRuby and MRI. Puma ( Github Page) is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications, and is considered the replacement for Webrick and Mongrel. Puma (with Nginx as reverse proxy server) Rails_env development # Rails environment. Root path_to_app/public # Be sure to point to 'public' folder! To serve an application with Nginx, configure it as follows: The installer will provide you with any additional information regarding the installation (such as installing additional libraries). In case a rails application is deployed with a sub-URI, like, some additional configuration is required, see the Passenger documentationįor Nginx, install the nginx-mod-passenger package (if passenger is not installed from gem), and run: If you are aiming to use Apache HTTP Server, install the mod_passenger package (if passenger is not installed from gem), and run:

Phusion Passenger is a module available for Nginx and Apache HTTP Server, that greatly simplifies setting up a Rails server environment. Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for It probably does not work without additional configuration): You can now easily start and stop unicorn using systemctlĪfter setting up Nginx, configure unicorn as an upstream server using something like this (Warning: this is a stripped example. etc/systemd/system/rvice ĮxecStart=/usr/bin/unicorn -D -E production -c /etc/unicorn/ Put the following contents in /etc/systemd/system/rvice: # /usr/bin/unicorn -D -E production -c /etc/unicorn/ GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true etc/unicorn/ working_directory "/srv/http/redmine" For example here is a configuration example based on this tutorial for Redmine: Then create a configuration file for your application in /etc/unicorn/. Explanation of differences between Unicorn and Mongrel. It is used by Github, and it uses an architecture that tries hard to find the best child for handling a request. Instead, a web server must sit between clients and Unicorn, proxying requests as needed. Unicorn is an application server that cannot talk directly to clients. Thin is a fast and very simple Ruby web server. Instead, you should use an application server such as #Thin, #Unicorn or Phusion Passenger.

The built-in Ruby On Rails HTTP server (called Puma) is convenient for basic development, but it is not recommended for production use. Note: If Ruby complains about not being able to find a JavaScript runtime, install nodejs.Ī test-page should be shown greeting you "Welcome aboard".
