1

Have been running into trouble setting up a Rails Api on an Apache server hosted on EC2, not sure if I am missing something but I have run through Phusions deployment docs for a passenger apache integration, this is the doc: https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/aws/apache/oss/trusty/deploy_app.html

The only issue is that as this is a Rails Api that I am working with, it has no views, and as such I am not sure what directory(doc says to reference public, to grab views from within)to reference in the passenger Virtual Host file, currently I only see the default apache .html when I hit the ec2 IP address and have no access to my rails api routes.

As a disclaimer, I am not so much looking for a specific answer to my problem as much as a direction or resource to research that will result in a resolution

TLDR: How do you set up a Rails Api on an Ubuntu 14.04 EC2 instance with an Apache server

cmds run:

sudo apt-get update
sudo apt-get install -y curl gnupg build-essential
sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | sudo bash -s stable
sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | sudo bash -s stable
login
sudo login
rvm
curl -sSL https://get.rvm.io | sudo bash -s stable
sudo gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | sudo bash -s stable
sudo chmod -R a+xwr /usr/local/rvm
rvm install ruby
sudo apt-get install -y dirmngr gnupg
   v  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
<sudo apt-get update
sudo apt-get install -y libapache2-mod-passenger
exit

sudo apt-get install apache2
sudo a2enmod passenger
sudo apache2ctl restart
sudo /usr/bin/passenger-config validate-install
sudo adduser out_break_data_api
touch $HOME/.ssh/authorized_keys
sudo sh -c "cat $HOME/.ssh/authorized_keys >> ~out_break_data_api/.ssh/authorized_keys"
sudo chown -R out_break_data_api: ~out_break_data_api/.ssh
sudo chmod 700 ~out_break_data_api/.ssh
sudo sh -c "chmod 600 ~out_break_data_api/.ssh/*"
sudo apt-get install -y git 
sudo mkdir -p /var/www/out_break_data_api
sudo chown out_break_data_api: /var/www/out_break_data_api
sudo chown out_break_data_api: /var/www/out_break_data_api
cd /var/www/out_break_data_api/
sudo -u out_break_data_api -H git clone https://myrepo.git code
sudo -u out_break_data_api -H bash -l
sudo nano /etc/apache2/sites-enabled/out_break_data_api.conf
sudo apache2ctl restart

Here is my Passenger VirtualHost Apache Config


<VirtualHost *:80>
    ServerName http://54.80.146.147/

    # Tell Apache and Passenger where your app's 'public' directory is
    DocumentRoot /var/www/out_break_data_api/code/public

    PassengerRuby /usr/local/rvm/gems/ruby-2.5.1/wrappers/ruby

    # Relax Apache security settings
    <Directory /var/www/out_break_data_api/code/public>
      Allow from all
      Options -MultiViews
      # Uncomment this if you're on Apache >= 2.4:
      #Require all granted
    </Directory>
</VirtualHost>
  • 1
    Could you add the log? What kind of EC2 did you create, e.g. ubuntu, rhel. How did you install it? Could you add the commands as the link could be deprecated in the future. – 030 Dec 31 '19 at 21:19
  • 2
    Exactly as stated in the doc, it is a Ubuntu 14.04 distro, installed via aws interface, will add edit the question to add more info – lexmasta Dec 31 '19 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.