How to install Ruby on Rails onto an existing Apache server?

July 9, 2019 299 views
API Ruby on Rails Apache LAMP Stack PHP MySQL Ubuntu 18.04

Hi,
So I've had a webserver with Ubuntu and Apache on the LAMP stack for about a year. It's mainly just a portfolio website.

I've just made an API using Ruby on Rails that is on my local machine and I've read up that you can host multiple different applications on the same droplet.

The idea is to make a subdomain such as www.api.Example.com
My existing website I have is www.Example.com
With this subdomain I wish to host my Ruby on Rails API, it uses PHP myadmin which I think I'll have to install on the LAMP stack? And it also has gems to install such as mysql2.

My question is how do I do this?

I've looked at so many tutorials but they're all saying a different thing and mentioning Nginx and I don't know how to get a subdomain. I bought my domain from Google so do I do it on Google Domains or do I do it on Digital Ocean?

So altogether I'm asking how to...
Make a subdomain such as www.api.Example.com?
Do I install PHPmyadmin on the main Apache bit and will it be on both my subdomain and main domain?
Is it possible to have a Ruby On Rails app and an existing Apache web server working concurrently?
How do I move my API from my PC over? Is it simply a case of copying over files? (To the Sites folder I'm guessing?)
How would I start it? (The usual rails s? or is it slightly different cause of the sub domain?
MySQL is already installed through the LAMP stack so I can just forget about it right?

Is that everything? It's been a good 7 months since I actually went on my server terminal so I'm probs a bit rusty with the commands.

Thanks in advance, I know I'm pretty bad at explaining myself but I think I did an alright job

1 Answer

Hello,

Yes, all the above is possible, you can run Ruby on Rails onto an existing Apache server and you don't need Nginx server. Here's a guide on how to set that all up:

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04

Before you start with the guide you can point your subdomain name to your Droplet's IP address. If you are using Google's namesevers you need to do that via your Google account, if you are using DigitalOcean's nameservers you need to make this DNS change via your Digital Ocean domain control panel.

Also before you proceed with the rails setup make sure to backup your droplet, in case that anything goes wrong, you can simply revert to that backup.

Regarding the PHPmyAdmin installation you can follow the steps here on how to install PHPmyAdmin manually with an existing Apache server, start from step Step 3:

https://websiteforstudents.com/install-phpmyadmin-latest-version-on-ubuntu-16-04-18-04-with-apache2-mariadb-and-php-7-2/

Hope that this helps! Let me know if you need any help!

Bobby

by Juraj Kostolanský
In this tutorial, we will demonstrate how to install [Phusion Passenger](https://www.phusionpassenger.com) as your Rails-friendly web server, which is easy to install, configure, and maintain. We will integrate it into Apache on Ubuntu 14.04. By the end of this tutorial, we will have a test Rails application deployed on our Droplet.
Have another answer? Share your knowledge.