Phusion Passenger not displaying CSS, Javascript files - ruby-on-rails

I have a Phusion install, configured with Rails 3.0.10 and Apache 2, and assets like CSS and Javascript are apparently being served, but not utilized by the browser.
So for instance when I hit the root url, the page renders, but CSS and javascripts are not used by the browser. I see GET requests coming through for each asset in the access logs.
I can visit those assets directly in my browser, going to stylesheets/application.css?1313636333 I see the correct application.css
I dont see permission errors in production logs, or apache error logs.
My VHost looks like:
<VirtualHost *:80>
ServerAdmin info#example.com
ServerName portal.example.com
DocumentRoot /app/example/public
<Directory /app/example/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Since you can access your static assets, the mime-type incorrectness might be the cause.
Take the output of the following:
curl --head http://portal.example.com/stylesheets/application.css
the result should contains "Content-Type: text/css"

Related

zend framework skeleton application not showing properly

I have installed the Skeleton Application manually. My application is kept in "D:\xampp\htdocs\zf2". I've created a virtual host in the following way, in httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
<Directory "D:/xampp/htdocs/zf2/public/index.php">
#DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but it does not shown properly and it gives the output
and the remain ing application with module and database shows also not shows in the proper way
but if i slightly modify in virtual host settings of
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
to
DocumentRoot "D:/xampp/htdocs/zf2/public"
then, skeleton application shows fine but when i configure module and database it gives error "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. zend sleleton application error"
can any one help me i have waste lot of time to set it but didn't.
You need to set document root to the folder not a file. The page looks messed up when pointing to index.php as documentroot because it cannot find the stylesheets.
The issue with configuring the module/database is probably a different issue, and you would have to post your module/database configuration to get help there.

Phusion Passenger + Apache 2 + Rails 3. Works on local network, not when accessed externally

The problem:
I have created a Rails project skeleton using rails new TestApp in the /var/www/ directory of my server. The Rails default index.html displays and works properly (i.e., you see the rails logo and when you click on "About your application's environment" you get a correct listing of the environment specifications used on the server) when I access the site from the same network on which the server is running. However, if I access the site from a machine on a different network than the server's, the page displays but I do not get the rails logo image, and clicking on "About your application's environment" results in the following error display on the page:
Not Found
The requested URL /TestApp/rails/info/properties was not found on this server
And that URL shouldn't be found, because it doesn't exist. However, TestApp/public/rails/info/properties does exist.
Configuration:
The site resides in /var/www/TestApp and I access it from a Sub-URI. I have created a symbolic link in /var/www/ called rails as follows: rails -> /var/www/TestApp/public, such that the project can be accessed from www.mydomain.com/rails. My Apache configuration is the following, note that I've omitted,changed, or shortened some parts within the <VirtualHost> tag for brevity:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/ex$
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.mydomain.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
.
.
.
#Rails Configuration
RailsBaseURI /rails
RailsEnv development
PassengerUserSwitching off
PassengerDefaultUser www-data
<Directory /TestApp/public>
Options FollowSymLinks -MultiViews
AllowOverride All
Allow from all
</Directory>
#End Rails Configuration
.
.
.
</VirtualHost>
A couple of things: the appropriate folders are owned by www-data with the appropriate permissions as defined by the Passenger documentation. When setting up the symlink and RailsBaseURI settings I followed the Passenger documentation.
I guess I'm at a loss here since everything seems to be working when accessing the website from the same network on which the server resides. I'm not sure why things aren't working out when accessing the site from a different network, but I feel like paths to certain resources/assets (like the rails logo) aren't resolving properly. Perhaps my symlink is configured inappropriately, or something is wrong with my Apache configuration?
Any help would be appreciated.
The issue of a somewhat broken default Rails page is not totally abnormal, it turns out.
I removed the default Rails page and replaced with another page that included some Rails code and everything worked like a charm.

Rails not rendering assets over SSL (404 Not Found error)

I am kind of new to Rails and am struggling with an issue that is preventing my assets to be found if I try to access my test app using an SSL connection.
As an example of what I am referring to, if you try to access
http://domain.com/testapp the default rails page loads fine and I have no issues at all.
You can also access a page I created using this route
http://domain.com/testapp/static_pages/home
However the same address, if accessed via HTTPS is returning 404 errors for all of my assets. I am also unable to access any routes (they all return 404).
https://domain.com/testapp
https://domain.com/testapp/static_pages/home
I am currently using an Apache server with Passenger installed, and here is what my virtual host configuration looks like:
<Directory /var/www/testapp/public>
PassengerEnabled on
PassengerAppRoot /var/www/testapp
RailsBaseURI /testapp
</Directory>
Any ideas of why this might be happening?
Thanks,
Rog
Thanks all, I finally figured out what was going on so in the interest of others having the same issue, the virtual host configuration was only being applied to the default port (80) so I had to specify port 443 as well.
<VirtualHost *:80 *:443>
<Directory /var/www/testapp/public>
PassengerEnabled on
PassengerAppRoot /var/www/testapp
RailsBaseURI /testapp
</Directory>
</VirtualHost>
For people using Media Temple's DV server, this configurations has to be specified in two separate files (make sure you remove the VirtualHost tags).
vhost.conf
vhost_ssl.conf
And don't forget to restart apache.
/usr/sbin/apachectl -K graceful

ruby rails passenger apache2 using Basic LDAP authentication in httpd.conf

I have a site that I want to force a user to log in via LDAP before they can see the front page of the website. This works with generic webpages fine, but doesn't work with a rails site running passenger on apache2. I've seen some references that this is because passenger doesn't respect the Directory command (or picks up before it gets to that directive). Is there a way to make this happen or do I need to add devise to the site instead?
<VirtualHost *:80>
ServerName test.example.com
DocumentRoot "/www/software/rails_site/current/public"
ErrorLog "/www/logs/software/rails_site/error_log"
CustomLog "/www/logs/software/rails_site/access_log" common
DirectoryIndex index.html
RailsEnv production
<Directory "/www/software/rails_site/current/public">
AuthType Basic
AuthName "Secure portal"
AuthBasicProvider ldap
AuthzLDAPAuthoritative on
AuthLDAPURL "info"
AuthLDAPBindPassword "pass"
require ldap-user usernames
Order deny,allow
Satisfy Any
</Directory>
</VirtualHost>
The above doesn't prevent the site from loading or do any challenge when first trying to load the site.
Try placing the authentication directives inside a Location instead of a Directory so that they will be triggered first by the incoming URI. Apparently Passenger has an order of operations associated with Directory directives.
This old post confirms that what you're trying to do (at least used to be) possible:
http://groups.google.com/group/phusion-passenger/browse_thread/thread/bb0ccee6b4a45bc0/429a34fb66dbde6d

Problem deploying Rails with Passenger to Mac OS X Leopard Server

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.

Resources