Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
You can indeed run multiple Rails applications on a single server. However, you will need to configure Nginx and Unicorn (or Passenger, Puma, etc.) for each Rails application you want to serve.
It is not recommended to switch apps by manually starting/stopping services or running “rails s” for production. This command starts a server intended for development, which is not suitable for handling real-world traffic.
Here’s a simplified process to set up a new Rails app alongside your existing one:
Create your new Rails app in a new directory:
- cd ~
- rails new my_second_app
You should create a separate Unicorn configuration file for your new app. The file might be located at ~/my_second_app/config/unicorn.rb, and it should be different from your existing Unicorn configuration to avoid conflicts.
Create a new Nginx configuration file for your new app. This will likely be a new file in the /etc/nginx/sites-available/ directory. The server block should have a different server_name from your existing configuration, and it should proxy requests to the Unicorn socket for your new app.
Create a symbolic link to the new Nginx configuration file in the sites-enabled directory:
- sudo ln -s /etc/nginx/sites-available/my_second_app /etc/nginx/sites-enabled/
Finally, you need to restart Unicorn and Nginx for your changes to take effect. How you do this depends on how you have set up your server. It might look something like this:
- sudo service unicorn_my_second_app restart
- sudo service nginx restart
This setup allows you to run both apps simultaneously, each with its own domain name. Note that if you are using the same droplet, you will need to point a new domain name to your droplet’s IP address for the new Rails application. This new domain should match the server_name in your Nginx server block for the new app.