Passenger error: No such file or directory – config/environment.rb

apache-2.2mac-osx-serverphusion-passengerredmineruby-on-rails

I installed Redmine on MacOSX Server 10.6.8 according to this installation description. So far everything works fine: When I start webrick the server serves the Redmine pages. The gems and redmine are installed under the user "redmine".

After that I aimed configuring apache2 with passenger as described here. As suggested by the description I also installed the passenger-pane which stores its virtual host configuration files in /private/etc/apache2/passenger_pane_vhosts. This is what I came up with after a lot of manual try and error. At least, now I can reach a passenger error page.

// redmine.vhost.conf
<VirtualHost *:80>    
  ServerName myserver
  ServerAlias localhost
  DocumentRoot "/Users/redmine/Sites/redmine"
# RackEnv production
# RackBaseURI /
  RailsEnv production
  RailsBaseURI /
# PassengerUser www-data
# PassengerGroup www-data
  <Directory "/Users/redmine/Sites/redmine">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

However, the passenger module still runs into the following errors.

Error message: No such file or directory - config/environment.rb

Screenshot of the passenger error page

The /var/log/apache2/error_log of the web server stated the following.

[warn] NameVirtualHost *:80 has no VirtualHosts
[notice] Apache/2.2.21 (Unix) Phusion_Passenger/3.0.12 configured -- 
  resuming normal operations
[ pid=21824 thr=2151905620 file=utils.rb:176 time=2012-06-01 18:22:07.126 ]: *** 
  Exception Errno::ENOENT in PhusionPassenger::ClassicRails::ApplicationSpawner 
  (No such file or directory - config/environment.rb) (process 21824, 
  thread #<Thread:0x0000010086f2a8>):

I experimented with the user switch functionality of passenger as described in the documentation – as you can tell from my configuration file. Though, I was not successful.


UPDATE: (04.06.2012)

After I changed the DocumentRoot and Directory path to /Users/redmine/Sites/redmine/public as suggested by Holger the Redmine site is reachable under http://myserver. However, it is not reachable under http://myserver/redmine; the 404.html of the public/ folder is served.
I guess Redmine is reachable under http://myserver because I overwrite the DocumentRoot for the whole Apache server (?). That is not what I want, though. Without setting the DocumentRoot in redmine.vhost.conf I encounter the following error page.

Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to 
use an ErrorDocument to handle the request.
Apache/2.2.21 (Unix) Phusion_Passenger/3.0.12 Server at myserver Port 80

Question: How must I configure the server to get the desired http://myserver/redmine url?

Best Answer

According to the Passenger documentation you have to use the public directory as the document root. In your case this would be /Users/redmine/Sites/redmine/public.

That way, only truly public files are in the document root and Passenger finds the correct application root. You should never put any actual code files (or even worse: configuration files) into the document root as they are freely readable by anyone.