Hello,
I followed this guide and everything went smooth!
I got a rails app up and running with no problems. But I have spent a lot of time tiring to get multiple apps running with no success.
I have tried to edit the TheApp/config/unicorn.rb for each app and /etc/nginx/conf.d/default.conf.
Are there any examples of how these files should be setup for multiple apps?
Also: When I run unicorn_rails -c config/unicorn.rb -D for the 2nd app i get the following error:
/usr/local/rvm/gems/ruby-2.1.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `read’: No such file or directory @ rb_sysopen - config/unicorn.rb (Errno::ENOENT)
Can anyone help please?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Have your tried VirtualHosts? With properly setup you can have different domains/folder.
For each app, you need to make sure unicorn is listening on a different socket. In the app’s <code>config/unicorn.rb</code>, change the socket value to be unique: <pre> listen “/tmp/unicorn.app_one.sock” </pre> Then in the Nginx configuration, you’ll need a new server block for each app. It will look something like: <pre> upstream app_one { # Path to Unicorn SOCK file, as defined previously server unix:/tmp/unicorn.app_one.sock fail_timeout=0; }
upstream app_two { server unix:/tmp/unicorn.app_two.sock fail_timeout=0; }
server { listen 80; server_name domain-for-app_one.com;
# Application root, as defined previously
root /root/app_one/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_one;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
server { listen 80; server_name domain-for-app_two.com;
# Application root, as defined previously
root /root/app_two/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_two;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
</pre>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.