Timothy
Timothy

Reputation: 4285

How to Serve Rails Web App with Apache and Passenger

I am serving eurohacktrip.org on a digitalocean vps with ubuntu12.04 and apache2.

Here is my apache virtual host file for it: /etc/apache2/sites-available/eurohacktrip.org

<VirtualHost *:80>
    ServerName eurohacktrip.org
    ServerAlias eurohacktrip.org

    DocumentRoot /var/www/eurohacktrip.org/public

    RailsEnv production
    PassengerEnabled on
    PassengerAppRoot /var/www/eurohacktrip.org/
    PassengerRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
    ServerAdmin [email protected]

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/eurohacktrip.org/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            # Order allow,deny
            Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

And I added these lines on my /etc/apache2/apache2.conf

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40
  PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>

And I did

service apache2 restart

But my site still doesnt work : http://eurohacktrip.org/
Strange enough It works on 3000 http://eurohacktrip.org:3000

I also had to Uncomment

gem 'therubyracer', platforms: :ruby 

and ran

bundle install

but still no luck. What could be missing?

Upvotes: 0

Views: 803

Answers (2)

Timothy
Timothy

Reputation: 4285

It turns out I simply wasn't reading the instructions from the passenger error page. I just needed to disable a gem "simple-captcha", ran bundle install and everything went back to normal. Thanks

Upvotes: 0

Ravendra Kumar
Ravendra Kumar

Reputation: 1082

 LoadModule passenger_module /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40
     PassengerDefaultRuby /home/deployer/.rvm/gems/ruby-1.8.7-p374/wrappers/ruby
   </IfModule>
        <VirtualHost *:80>
              ServerName yourservername
              RailsEnv production
              # !!! Be sure to point DocumentRoot to 'public'!
              DocumentRoot /home/user/apps/projects/myapp/public
              <Directory /home/user/apps/projects/myapp/public>
                 # This relaxes Apache security settings.
                 AllowOverride all
                 # MultiViews must be turned off.
                 Options -MultiViews
              </Directory>
        </VirtualHost>

if you face any problem follow this link

http://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger

Upvotes: 1

Related Questions