How to run multiple rails applications on different sub urls with same domain

Posted by : on

Category : Rails

Hello There, Today I am going to tell you how you can run multiple rails applications on a single server with different sub urls. I am using ````nginx +passenger``` to run applications.

Here is an implementation how can we run multiple rails applications over a single machine:

Deploy both applications on server:

First step to deploy both application on single server.

Edit nginx configs

run command sudo nano /etc/nginx/site-enabled/APPLICATION_CONFIG and change root and base uri as like following lines of code in the file:

root PATH_OF_FIRST_APP/public;
passenger_base_uri /APP2;

Restart nginx service:

sudo service nginx restart

ln -s PATH_OF_SECOND_APP/public PATH_OF_FIRST_APP/public/APP2

Restart passenger:

touch tmp/restart.txt

Now you can visit your ip/domain, as you can see:

  • www.example.com will be serving the first application.
  • www.example.com/APP2 will be service the second application.


About Ram Laxman Yadav
Ram Laxman Yadav

Senior Software Engineering Professional | Tech Enthusiast | Mentor | Payments | Hospitality | E-Commerce, based in NCR, India

Email : info@ramlaxman.co.in

Website : https://ramlaxman.co.in