Nicolò Ciraci
Nicolò Ciraci

Reputation: 678

Mac OSX Lion Apache + RubyOnRails + mod_passenger

I'm trying to learn how to develop web application with Ruby On Rails but I've incurred in a silly error. I'm trying to use Phusion Passenger aka mod_rails to use Apache instead of WEBrick; I've installed the module via gem and run the

sudo passenger-install-apache2-module

command to install passenger; then I edited the http.conf file adding

LoadModule passenger_module /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19
PassengerRuby /Users/Stopped/.rvm/wrappers/ruby-1.9.3-p327/ruby

added the VirtualHost

<VirtualHost *:80>
    ServerName rails.local
    DocumentRoot "/Users/Stopped/RoR/prova/public"
    <Directory /Users/Stopped/RoR/prova/public>
        AllowOverride all
        Options -MultiViews
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

restarted Apache with sudo apachectl restart but It's not working :( If I lookup in localhost I see the "It works!" page but if I go at rails.local there is not my Rails app :(

Passenger is loaded

Apache/2.2.22 (Unix) Phusion_Passenger/3.0.19 DAV/2 PHP/5.4.9 Server at localhost Port 80

Any ideas?

PS: This is "apachectl -S" output

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
         port 80 namevhost rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK

SOLUTION

Uhm... I solved it, adding 127.0.0.1 rails.local to my hosts file but I can't understand why; can someone explain this to me? ._.

Upvotes: 3

Views: 620

Answers (1)

Tr&#232;s
Tr&#232;s

Reputation: 804

you can't use a wildcard with localhost in your hosts file. you have to explicitly specify each subdomain for localhost in your hosts file. if you're looking for an alternative, you could buy a domain name and point that domain name to 127.0.0.1 with a wildcard. you could even go a step further and have a skeleton app which points different subdomains to different applications by mapping the routes.

Upvotes: 1

Related Questions