1

I can't seem to pinpoint where the issue is, but I can't seem to get my app deployed to a sub URI. My gut says it's between my vhost config and my symlink, but this is my first time working with vhosts and passenger this extensively.

I am greeted with the passenger error when I try to hit http://example.com/app...

No such file or directory - config.ru

It shows Application Root:

/home/username/public/example.com/public

So as far as everything else goes... directory structure of site:

example.com/
    |-- public/
        |-- index.php
        |-- app/
            |-- config.ru         
            |-- app.rb      
            |-- public/           
            `-- tmp/              
                `-- restart.txt 

vhosts in /etc/apache2/sites-available/example.com:

# domain: example.com
# public: /home/username/public/example.com/

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin email@example.com
  ServerName  www.example.com
  ServerAlias example.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/username/public/example.com/public
   <Directory /home/username/public/example.com/public>
      Allow from all
   </Directory>

  RackBaseURI /app
  <Directory /home/username/public/example.com/public/app>
      Options -MultiViews
  </Directory>

  # Log file locations
  LogLevel warn
  ErrorLog  /home/username/public/example.com/log/error.log
  CustomLog /home/username/public/example.com/log/access.log combined
</VirtualHost>

symlink I made:

ln -s /home/username/public/example.com/public/app/public /home/username/public/example.com/app

config.ru:

#!/usr/bin/env ruby
require 'sinatra'

require File.expand_path('app.rb',__FILE__)

run Sinatra::Application

and the app.rb:

#!/usr/bin/env ruby
# encoding: UTF-8
require 'sinatra'

get '/' do
    "App!"
end

Not really sure what could be going wrong here, but I have multiple sites on this VPS so the directory structure is a little funky with so many public folders. I may be confusing myself.

  • 1
    It's been a while since I ran anything on Apache, so forgive a possibly stupid question, but why is the Sinatra app code sitting inside `example.com/public`? I think that should only for static files and definitely not application code. Take a look [at this answer](http://stackoverflow.com/a/3373406/335847) and see if that helps. – ian Mar 21 '13 at 09:26
  • If I move everything into /example.com it seems to mess everything up. It seems like based on Passenger's doc the "apps" aren't usually in the same folders as the sites themselves. I guess that's why symlinks are important. – Matthew K. Turner Mar 21 '13 at 20:38
  • 1
    I'm looking [at this in the docs](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application_including_rails_gt_3) which doesn't have the same layout or directives. Don't put your application in a public folder, public folders are only ever for static assets. Copy what's in [4.3 Deploying to a Sub URI](http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri) and you'll get a lot closer. – ian Mar 21 '13 at 21:49
  • You have set up your VHOST file to point to "/home/username/public/example.com/public". From this Passenger will assume /home/username/public/example.com to be the directory in which you ruby application is located and look for config.ru over there. – Nikhil Mar 22 '13 at 00:19
  • If you are trying to deploy the app to a sub URI of example.com then move the application to another folder and symlink it (http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri) - everything in public is treated as static assets and made available at http://example.com – Nikhil Mar 22 '13 at 00:27
  • After understanding a little more closely whats going on in the 4.3 "Deploying to a Sub URI" section in the Passenger manual I realized they didn't even have the app in the same folder as the site and it was more of a sibling element to the site. I guess I was under the impression I would at least want it inside /example.com even if it wasn't in public. I moved it out and everything seems to work OK, but now all of my links in my app need to be prefixed with the directory its in (eg, href="/app/css/styles.css") Do I need middleware to work with routing/base_url? – Matthew K. Turner Mar 22 '13 at 15:09

0 Answers0