I have been studying Ruby on Rails for just over a month. I have deployed an app to a production VPS and am getting comfortable with Ruby/Rails in general. I am now trying to learn and build apps in one of the more recent Rails versions. Since multiple versions of Ruby/Rails is a commonplace concept among Rails developers, I figure I should play around with coding in different versions and maintaining those apps in a production environment.
It seems like from my googling and stackoverflow searches that what I am trying to do is not common. However, it forms the foundation for everything I want to do/learn about Rails and Passenger/Apache on my server (based on above goals). That is, hosting multiple Rails applications under the same domain name, some being the same ruby/rails version and others a different version. So:
mywebsite.com <--- Ruby 2.3.4 / Rails 4.2.5
mywebsite.com/profile <--- a separate app: Ruby 2.3.4 / Rails 4.2.5
mywebsite.com/cool-app <--- a separate app using the latest and greatest features: Ruby 2.5.0 / Rails 5.1.4
When I search stackoverflow for "multitenancy rails passenger", there are exactly 0 results. There is also this link: https://www.phusionpassenger.com/library/deploy/apache/
Which has an article called "Deploying multiple apps on a single server (multitenancy)", but it doesn't exist yet and says: "to-do"! I've been trying to stumble my way through it, but it seems like there is too much I don't understand to just copy and paste someone else's code and get it to work.
It seems like part of the trick to getting these things to work is with different VirtualHost setups.
Here is what I have tried for the above applications:
mywebsite.com (main site):
<VirtualHost *:80>
ServerName mywebsite.com
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /var/www/login_app/code/public
PassengerRuby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby
# Relax Apache security settings
<Directory /var/www/login_app/code/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
<Directory /var/www/login_app/code/public/profile>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
PassengerBaseURI /profile
</VirtualHost>
mywebsite.com/profile (same Ruby/Rails versions as main site)
<VirtualHost *:80>
ServerName mywebsite.com
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /var/www/test_app/code/public
PassengerAppRoot /var/www/test_app/code
PassengerRuby /usr/local/rvm/gems/ruby-2.3.4/wrappers/ruby
# PassengerBaseURI /profile
# Relax Apache security settings
<Directory /var/www/test_app/code/public>
PassengerEnabled on
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
Haven't even attempted to do a VirtualHost file for the 3rd app. I would assume that the PassengerRuby field would tell Passenger to use the correct/different Ruby interpreter. But again, I can't find anyone who does this, and I especially can't find any explanations for what is being done. When I find something even remotely close, it was from 6 years ago and the code is obsolete because Passenger supposedly handles this pretty easily now (but where are the examples?!).
It seems like when I go to mywebsite.com/profile, the main site app is still handling the route, as it logs to main_site_path/log/production.log (not the second app's log).
Any help would be appreciated, but since I know I should be specific, here are some specific things it might help me to know?:
Should there be a Passenger process running for each app when I do passenger-memory-stats, or just the main one?
How do I correctly define that /profile off my main domain should be handled by a different Rails App (different VirtualHost if applicable)?
Thanks.