How can I get RVM/Passenger/Apache2 to play nicely together

So there are 2 other files that are in the sites-available directory.

- default - default-ssl

I changed the name of the of the file called site to default in the sites-available directory and restarted apache and that was still no luck. I also moved the site application into /var/www and www-data the owner /var/www/*. Changed the location of RootDocument in the site file in sites-available and still no luck.

I am not sure how to make my .rvm directory readable to the rest of my system without making my entire home directory readable to the entire system. I assume that is not a good idea.

Vell, with your setup as far as I can see, you can without changing the apache site and localhost files at all.

You can create a symbolic link from your /var/www directory to your Rails directory, something along these lines:

$sudo ln -s /home/vmcilwain/www/site/public /var/www/site

Now, if you go to http://localhost/site you should get your Rails site up.

Of course, it is different if you want to be able to get your site to answer to http://localhost directly. One way I have achieved this is to edit /etc/apache2/sites-available/default (only change is at top, DocumentRoot, and removing the <directory /var/www> section which isn't really necessary):

<VirtualHost *:80>         ServerAdmin webmaster@localhost

        DocumentRoot /home/binni/mysite/public         <Directory />                 Options FollowSymLinks                 AllowOverride None         </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>

</VirtualHost>

-----Oprindelig meddelelse-----

Brynjolfur,

Setting up a sym link seems to have done the trick. Pointing that to my www directory in my home directory seems to have done the trick.

I have also set the www directory in my home directory to be read/ write by "other" as well.

Once I took my browser to http://llocalhost/site everything came up fine.

I don't recall changing any permissions to my .rvm directory in my home directory.

So now that I know that that works, I will try this process all over again to make sure I have the steps down right.

I would like to thank you all for being patient with me as I try to get all of this working.

Hmm one more question before I call this a complete success, I just tried to create a new scaffold but it looks like I continue to get the welcome board page of my app. Is this because my sym link is only pointing at public?

I removed the index.html file from the application and created a model called "me":

bundle exec rails generate scaffold me email:string bundle exec rake:migrate

when I then try to go to http://localhost/mes I get the requested URL / site/mes was not found.

Nevermind, my sym link was pointing to an old directory that had the same application name which was the test to see if it was working using localhost 3000. So at this point When I set up the sym link correctly and I hit the location with a browser, I am getting a list of the contents of public. Maybe that is the intended behavior until I recreate my basic scaffold.

Go to http://localhost/site/me (assuming that Rails previously answered to http://localhost/site and the model is called "me" and not "mes"

Alternatively you could edit the config/routes.rb file and tell it to point root to the "me" folder. The command is somewhat different depending on your version of Rails but in my current 3.10 the line would look like this:

root :to => 'me#index'

-----Oprindelig meddelelse-----

Hi, I forgot one thing that you might need to do. When using a symlink I think you need to add some lines to the bottom of the apache config file. Here is what I did in a previous setup which works:

$sudo ln -s /home/binni/rails/testapp/public /var/www/public

$sudo vim /etc/apache2/sites-available/default         Added lines:         RailsBaseURI /testapp         RailsEnv development $sudo service apache2 restart

The symlink is slightly different from the one I sent you earlier, it creates a "public" link in the end of the command.

-----Oprindelig meddelelse-----

Sorry to confuse you - this has something to do with Adhearsion which I am installing along with Rails. The original symlink should probably work fine, and I think it's time I withdrew ...

-----Oprindelig meddelelse-----

So much for thinking things were working. Nothing I have tried has worked. Thanks for the suggestions all but at this point, Im frustrated enough that I am going to take a break for a while before I throw this machine out the window and drop rails entirely.

It shouldn't be this hard to get a production server setup.

Adding those lines to the site I at least am getting a passenger error which is better than not getting anything at all. That is finally progress.

Thank you for the additional info. I have also put everything into the apache2 file instead of splitting them into different files. Once I step away for a while and come back to it to try and get the rest working I will split the files as Apache would want me to.

Would I be able to switch the RailsEnv when I am finally ready to put this into production mode?

OK, So through all the pain an anguish I think I finally have a working server (NO JOKE!)

Here are the steps that I have done to get this working with apache, passenger, and rvm

After installing all the necessary software software update rvm (single user) rails passenger passenger apache module

I did the following: Created directory apps in my home directory Created a rails app called site in the newly created apps directory Added the following to the apache2.conf file

<VirtualHost *:80> ServerName localhost DocumentRoot /var/www RailsBaseURI /site RailsEnv development </VirtualHost>

LoadModule passenger_module /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/ gems/passenger-3.0.11/ext/apache2/mod_passenger.so

PassengerRoot /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/ passenger-3.0.11 PassengerRuby /home/vmcilwain/.rvm/wrappers/ruby-1.9.2-p290/ruby

Then created a symlink called sites that points to /home/vmcilwain/ apps/site/public

From there, I can hit http://localhost/site and get the index page of the sites app. When I click on the link for looking at the application environement the information comes up which tells me that my application is working as it should be.

Thanks everyone for being patient with me and my frustration.