简体   繁体   中英

Deploy ruby on rails app with passenger and apache

I want to deploy my ruby on rails application on Red Hat Enterprise Linux Server release 6.5 server I have done the following:

Server version: Apache/2.2.15 (Unix)

rvm install ruby

gem install rails

gem install passenger

passenger-install-apache2-module

then I added the following line on my httpd.conf file

   LoadModule passenger_module /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
     PassengerDefaultRuby /home/myname/.rvm/gems/ruby-2.1.2/wrappers/ruby
   </IfModule>

alos I added the following to my httpd.conf

   <VirtualHost *:80>
  ServerName www.whatever.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/whatever/public    
  <Directory /var/www/whatever/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
     # Uncomment this if you're on Apache >= 2.4:
     #Require all granted
  </Directory>

Additional info rvm 1.25.31

I restarted the httpd and I cannot see my app running on whatever.com I have bought the domain and redirected it to the IP of my machine. What is wrong?

You need to uncomment the line indicated below and restart your apache service ( sudo service apache2 restart or similar sudo /etc/init.d/apache2 restart )

  <VirtualHost *:80>
  ServerName www.whatever.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/whatever/public    
  <Directory /var/www/whatever/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
     # Uncomment this if you're on Apache >= 2.4:
 --->    Require all granted
  </Directory>

This is a common issue with the default stuff from passenger. Chances are you're on a newer version of apache which means # Uncomment this if you're on Apache >= 2.4: would apply.

There's a number of reasons why this can happen, @user1876128 had some internal network issues and it wasn't acutally apache at fault.

For this apache setup to work, your network needs to allow http traffic to port 80 of your server box.

It's also advisable to allow traffic on port 3000, so you can run up a rails dev server on the same address (plus :3000) to check any changes before they're up.

You can log in to most domestic routers by pointing your browser at 192.168.0.1 or 192.168.1.1, then using the password (which is either written on your router, or the default password you can find online, or you've already changed it). And setting up a service for port 80 and your server box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM