Problem deploying Rails with Passenger to Mac OS X Leopard Server - ruby-on-rails

I'm spinning my wheels... Apache is working and serving static html, png, etc. normally. Trying to get Passenger to serve a rails app out of www.mydomain.com/rails/
as it stands when i try to hit my app: www.mydomain.com/rails/myapp/railsclassname
I get only an Apache 403 Errors. Nothing in myapp's Production Log.
Apache2 access.log:
"GET /rails/ HTTP/1.1" 403 1085
Apache2 error.log:
[Fri Jun 11 22:44:01 2010] [error] [client 10.0.1.41] File does not exist: /Library/WebServer/wwwroot/rails/railsclassname
i've even tried www.mydomain.com/myapp/classname
Passenger, obviously, isn't routing requests made into my sub-folder rails/ to my rails app. not sure where i've screwed up. the most obvious thing is "Passenger doesn't seem to be running"... instructions I've followed just say to sudo apachectl graceful, which i've done (as well as stopped/started). new to this so go easy on me!
Here's some info that might be helpful. happy to provide more as needed...
As per some instruction # Passenger site i've created a symlink from /Library/WebServer/myapp/rails -> /Library/WebServer/rails/myapp/public
myhost:myapp joe$ passenger-config --root
/Library/Ruby/Gems/1.8/gems/passenger-2.2.14
myhost:myapp joe$ passenger-status
ERROR: Phusion Passenger doesn't seem to be running.
apollo:myapp joe$ cat /etc/httpd/httpd.conf
...
<removed for brevity>
...
# Copied From Passenger Installer
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.14/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.14
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
# End Passenger Installer
NameVirtualHost *
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot /Library/WebServer/rails/myapp/public # <-- be sure to point to 'public'!
RackBaseURI /rails
<Directory /Library/WebServer/rails/myapp/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
order allow,deny
Allow from all
</Directory>
</VirtualHost>
This last bit from NameVirtualHost on is pieced together from a number of online material i've found...as i've been desperately trying to find something/anything that'll show Passenger at least has a pulse!?!

So, you've got
www.mydomain.com
www.mydomain.com/rails
These both point to different websites (lets call them main and rails), the code for each site might be saved on the file system like so:
/Library/WebServer/main/
/Library/WebServer/rails/
We create a symlink from your rails app's public folder to a folder called rails in your main app:
ln -s /Library/WebServer/rails/public /Library/WebServer/main/rails
Then we create a VirtualHost for the main site (not the rails one, and I'm assuming the main site is not rails) and add the rails app as a sub URI, like so:
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot /Library/WebServer/main
<Directory /Library/WebServer/main>
Allow from all
</Directory>
RackBaseURI /rails
<Directory /Library/WebServer/main/rails>
Options -MultiViews
</Directory>
</VirtualHost>
(If you already have a VirtualHost set up for your main website, you can add the RackBaseURI and preceding Directory declaration to that instead).
Now restart apache and you should be able to go to:
www.mydomain.com/rails
and see the "Welcome to Rails" page, or:
www.mydomain.com/rails/controllername
Hope that helps.

Related

Trying to get my ROR site up and running...getting a 404

running a R.o.R. site on passenger. Passenger is running fine, but I'm not sure if I am having an issue with the way I setup my vHosts or what, but It's returning a the apache start page, and not my application.
When I run
passenger-status
here is the message:
Version : 4.0.18
Date : 2013-09-26 10:42:03 -0400
Instance: 20958
----------- General information -----------
Max pool size : 6
Processes : 0
Requests in top-level queue : 0
----------- Application groups -----------
[USERNAME#gregorymurray relaunchradio]#
Here is the passenger stuff in my httpd.conf:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger- 4.0.18/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.18
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
PassengerDefaultUser root
No problem that I see there, here is my vhost.conf file in the main directory of my site:
ServerName gregorymurray.com
ServerAlias gregorymurray.com
DocumentRoot /var/www/vhosts/gregorymurray.com/relaunchradio/public
PassengerAppRoot /var/www/vhosts/gregorymurray.com/relaunchradio
<Directory "/var/www/vhosts/gregorymurray.com/relaunchradio/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsEnv production
RailsBaseURI /
Here are the two links I followed in the process of getting this running:
http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers
https://coderwall.com/p/lu3nfa
Are you sure apache2 is finding the vhost.conf file? Are you using some kind of shared hosting that requires placing that file in your website's main directory? Because, that's not the normal setup. The virtual hosts file belongs under /etc/apache2 or /etc/httpd depending on whether using Ubuntu or centOS. Look at your apache conf file to find out where it's looking for the virtual hosts.
Open /etc/httpd/conf/httpd.conf and look for vhost.conf. Or look for a Include directive of the full path to your gregorymurray.com. I doubt either one will be found. Which means you need to move vhost.conf to /etc/httpd/conf/sites-enabled/vhost.conf and add Include sites-enabled/ in your httpd.conf just above the passenger module stuff.
Placing your vhost.conf in your website directory would require that you alter your httpd.conf to look in that website directory for a virtual host conf file. That's not the default setup or conventional setup.

Rails 3 + passenger conf file

I have been trying to install a rails app on a box that originally was used for multiple php applications. I installed passenger and created a conf file but I am confused about how it all works together.
What should my ServerName be if i want to access a Rails app? The box is a debian squeeze running apache2 with passenger module installed. Below is my conf file. I currently have to go to xxx.xxx.xxx.xxx/leoadmin/public to get the application to run properly. I have the following htaccess in the public directory. Which I think is unnecessary if my conf file is configured correctly.
I think my main issue is the misconfiguration of the conf file. I believe the conf file is being loaded but i don't understand why i still need the htaccess for me to see any action.
.htaccess
#PassengerEnabled On
PassengerAppRoot /var/www/leoadmin/
#Options -MultiViews
#PassengerResolveSymlinksInDocumentRoot on
#Set this to whatever environment you'll be running in
RailsEnv production
#RackBaseURI /var/www/leoadmin
vhost config
<VirtualHost *>
ServerName leoadmin
DocumentRoot /var/www/leoadmin/public
<Directory /var/www/leoadmin/public>
Allow from all
</Directory>
Alias /leoadmin /var/www/leoadmin/public
<Location /leoadmin>
SetEnv RAILS_RELATIVE_URL_ROOT "/leoadmin"
PassengerAppRoot /var/www/leoadmin
</Location>
ErrorLog /var/log/apache2/leoadmin-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/leoadmin-access.log combined
</VirtualHost>
I had nothing but pain and more pain trying to get this sorted a few months back, my configuration allows me to do sub URIs, so I'm not sure if that's what you want, but it'll be along these lines. I've never needed a .htaccess file for this setup:
NameVirtualHost *:80 <VirtualHost *:80>
ServerName www.test.co.uk
DocumentRoot /web/rails
<Directory /web/rails>
Allow from all
</Directory>
RailsBaseURI /test
RailsEnv development
<Directory /web/rails_projects/test/>
Options -MultiViews
</Directory>
For me /web/rails is a root directory, from there I have a number of symlinks to my /home/ directory where I store my projects. ServerName is whatever qualified name you're using for the machine that's going to be recognised.
(just in case, I'm running Passenger 3.0.9, and Rails 3.2.11)

confused about apache server virtual host

So I configured a VirtualHost in the httpd-vhosts.conf directory, but whenever I navigate to the servername, it seems to always give me the page listed in httpd.conf.
I am new to apache web server and am not sure what else I need to do.
In my httpd-vhosts.conf I have
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName helloworld.com
DocumentRoot /Users/username/Desktop/RailsDemo/depot/public/
<Directory /Users/username/Desktop/RailsDemo/depot/public/>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In my httpd.conf, I have default settings, so I didn't change anything since install.
Also, I have matched helloworld.com to the correct ip address. Typing helloworld.com into the browser produces the wrong view...it produces the view indicated in httpd.conf.
If this helps, I am trying to do p. 238 of Pragmatic Agile Web Development with Ruby on Rails (4th Edition) -- Iteration K1: Deploying with Phusion Passenger and MySQL
Any help would be appreciated, thanks!
You seem to be running Mac OS X. In your httpd.conf, you will have the lines;
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Remove the comment, making it
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
Restart apache, and that should activate your named vhost.

Passenger on Ubuntu still only serving default index.html

Trying to get my server to serve my rails apps.
I have a test app installed, apache2 and passenger have been installed have I have added the following to the apache2.conf
# Include the virtual host configurations:
Include sites-enabled/
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName 192.168.1.67
DocumentRoot /home/john/Public/test-app
</VirtualHost>
Clearly, I am misunstanding something, because I think that should redirect calls to my local IP to my rails app. It is not. It is going to the default apache index.html.
What am I doing wrong?
UPDATED answer:
I think you are missing the "Directory" node. try using this config code:
(assuming your project path is: /home/john/Public/test-app)
<VirtualHost *:80>
DocumentRoot /home/john/Public/test-app/public
RailsEnv development
<Directory /home/john/Public/test-app/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
This is how I usually do it:
<VirtualHost *:80>
ServerName mysubdomain.betamaster.us
DocumentRoot /var/www_home/mysubdomain/
</VirtualHost>
After applying these changes make sure to execute
/etc/init.d/apache2 reload
in order to reload the server configuration.
I had the same symptoms in this question but it was a different problem. My apache install already had a Virtual host enabled, so I had to disable it and enable my own with the commands
sudo a2dissite default
sudo a2ensite myapp
where default was the name of the Virtual Host file included by default in sites-avaliable/ and myapp is the file i added.
Hopefully this helps someone.

Controller pages inaccessible in new RoR project...why?

I set up a new RoR project on MAC OS Leopard, created a repository, svn added the whole Rails project, committed, checked out at my site, set up a vhost (see below), and I cannot get to a new controller page I created (/mycontroller/index). I CAN get to the "Welcome Aboard" page. I have another Ruby install (Redmine project management software) running with Apache.
I get this:
Not Found
The requested URL /developer was not found on this server.
Apache/2.2.8 (Ubuntu) mod_fastcgi/2.4.6 PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch mod_scgi/1.12 Server at colorubooks.chadjohnson.ath.cx Port 8080
Here is my vhost setting:
<VirtualHost *:80>
ServerName mysite.mydomain.ath.cx
ServerAdmin email#gmail.com
DocumentRoot /srv/www/mysite.mydomain.ath.cx/public
RailsEnv development
<Directory "/srv/www/mysite.mydomain.ath.cx/public">
Options Indexes ExecCGI FollowSymLinks -MultiViews
Order allow,deny
Allow from all
AllowOverride all
</Directory>
</VirtualHost>
First:
In DocumentRoot you missed a /
change:
DocumentRoot /srv/www/mysite.mydomain.ath.cxpublic
to:
DocumentRoot /srv/www/mysite.mydomain.ath.cx/public
then you should be able to see static files in the /public directory (like the welcome aboard page)
Now I have a question for you... I presume that you want to use apache to deploy... Have you already installed and setup passenger (mod_rack) apache module?
Link to easy passenger install guide: http://modrails.com/install.html
enjoy!

Resources