Passenger: RailsBaseURI case sensitive? - ruby-on-rails

I used Passenger to deploy a RoR app to a sub URI on my domain. The problem I'm facing is that the sub URI seems to be case sensitive. Navigating to http://mydomain.com/RailsApp resolves fine. However, if I go to http://mydomain.com/railsapp, http://mydomain.com/railsApp, or any other variation, I get a 404 error. How can these requests using different casings get resolved correctly?
Here is my Apache configuration file:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /www/mydomain/public
<Directory "/www/mydomain/public">
RailsEnv "production"
Order allow,deny
Allow from all
</Directory>
RailsBaseURI /RailsApp
<Directory "/www/RailsApp/public">
RailsEnv "development"
Options -MultiViews
</Directory>
</VirtualHost>
Any help is much appreciated. Thanks!

You could look into using mod_rewrite and matching it case insensitive there.
Some links to get you started :)
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.2/misc/rewriteguide.html

Thanks ba for pointing me in the right direction.
I did some research and found the mod_speling module. This not only makes the URL case-insensitive but also checks for spelling errors.
To enable mod_speling:
sudo /usr/sbin/a2enmod speling
sudo /etc/init.d/apache2 force-reload
sudo /etc/init.d/apache2 restart
To use mod_speling, include the directive CheckSpelling on in your virtual host section:
<VirtualHost *:80>
CheckSpelling on
...
</VirtualHost>

Related

How to change the URL from "localhost" to something else, on a local system using wampserver?

On a Windows machine, there's a system running on the local wampserver, but while the application is running on localhost, the URL says otherwise.
While I would expect the URL to be like this based on the directory structure:
http://localhost/pro/include/db_report.php
The developer has managed to do this:
http://ap-mispro/pro/include/db_report.php
So instead of localhost, the URL says ap-mispro.
And both URLs work fine.
How is the second URL made? I tried checking out the wampmanager.ini and wampmanager.tpl but maybe I didn't know what to look for?
WINDOWS + WAMP solution
Step 1
Go to C:\wamp\bin\apache\Apache2.2.17\conf\ open httpd.conf file and change #Include conf/extra/httpd-vhosts.conf to Include conf/extra/httpd-vhosts.conf i.e. uncomment the line so that it can includes the virtual hosts file.
Step 2
Go to C:\wamp\bin\apache\Apache2.2.17\conf\extra and open httpd-vhosts.conf file and add the following code
<VirtualHost myWebsite.local>
DocumentRoot "C:/wamp/www/myWebsite/"
ServerName myWebsite.local
ServerAlias myWebsite.local
<Directory "C:/wamp/www/myWebsite/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
change myWebsite.local and C:/wamp/www/myWebsite/ as per your requirements.
Step 3
Open hosts file in C:/Windows/System32/drivers/etc/ and add the following line ( Don't delete anything )
127.0.0.1 myWebsite.local
change myWebsite.local as per your name requirements
Step 4
restart your server. That's it
WINDOWS + XAMPP solution
Same steps as that of WAMP just change the paths according to XAMPP which corresponds to path in WAMP
Copy the hosts file and add 127.0.0.1 and name which you want to show or run at the browser link. For example:
127.0.0.1 abc
Then run abc/ as a local host in the browser.
They are probably using a virtual host (http://www.keanei.com/2011/07/14/creating-virtual-hosts-with-wamp/)
You can go into your Apache configuration file (httpd.conf) or your virtual host configuration file (recommended) and add something like:
<VirtualHost *:80>
DocumentRoot /www/ap-mispro
ServerName ap-mispro
# Other directives here
</VirtualHost>
And when you call up http://ap-mispro/ you would see whatever is in C:/wamp/www/ap-mispro (assuming default directory structure). The ServerName and DocumentRoot do no have to have the same name at all. Other factors needed to make this work:
You have to make sure httpd-vhosts.conf is included by httpd.conf for your changes in that file to take effect.
When you make changes to either file, you have to restart Apache to see your changes.
You have to change your hosts file
http://en.wikipedia.org/wiki/Hosts_(file) for your computer to know
where to go when you type http://ap-mispro into your browser. This
change to your hosts file will only apply to your computer - not
that it sounds like you are trying from anyone else's.
There are plenty more things to know about virtual hosts but this should get you started.
please refer http://complete-concrete-concise.com/web-tools/how-to-change-localhost-to-a-domain-name
this is best solution ever
for new version of Wamp
<VirtualHost *:80>
ServerName domain.local
DocumentRoot C:/wamp/www/domain/
<Directory "C:/wamp/www/domain/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
After another hour or two I can actually answer my own question.
Someone on another forum mentioned that you need to keep a mention of plain ol' localhost in the httpd-vhost.conf file, so here's what I ended up with in there:
ServerName localhost
DocumentRoot "c:/wamp/www/"
DocumentRoot "C:/wamp/www/pocket/"
ServerName pocket.clickng.com
ServerAlias pocket.clickng.com
ErrorLog "logs/pocket.clickng.com-error.log"
CustomLog "logs/pocket.clickng.com-access.log" common
<Directory "C:/wamp/www/pocket/">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Exit WAMP, restart - good to go. Hope this helps someone else :)
go to C:\Windows\System32\drivers\etc and open hosts file and add
this
127.0.0.1 example.com
127.0.0.1 www.example.com
then go to C:\xampp\apache\conf\extra open httpd-ajp.conf file and add
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/pojectroot"
ServerName example.com
ServerAlias www.example.com
<Directory "C:/xampp/htdocs/projectroot">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
WINDOWS + MAMP solution
Step 1
Go to S:\MAMPenter code here
\bin\apache\conf\ open httpd.conf file and change
#Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf i.e. uncomment the line so that it can includes the virtual hosts file.
Step 2
Go to S:\MAMP\bin\apache\conf\extra and open httpd-vhosts.conf file and add the following code
<VirtualHost myWebsite.local>
DocumentRoot "S:\MAMP\htdocs/myWebsite/"
ServerName myWebsite.local
ServerAlias myWebsite.local
<Directory "S:\MAMP\htdocsmyWebsite/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
change myWebsite.local and S:\MAMP\htdocs/myWebsite/ as per your requirements.
Step 3
Open hosts file in C:/Windows/System32/drivers/etc/ and add the following line ( Don't delete anything )
127.0.0.1 myWebsite.local
change myWebsite.local as per your name requirements
Step 4
restart your server. That's it
This method will work for xamp/wamp/lamp
1st go to your server directory, for example, C:\xamp
2nd go to apache/conf/extra and open httpd-vhosts.conf
3rd add following code to this file
<VirtualHost myWebsite.local>
DocumentRoot "C:/wamp/www/php-bugs/"
ServerName php-bugs.local
ServerAlias php-bugs.local
<Directory "C:/wamp/www/php-bugs/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
For DocumentRoot and Directory add your local directory
For ServerName and ServerAlias give your server a name
Finally go to C:/Windows/System32/drivers/etc and open hosts file
add 127.0.0.1 php-bugs.local and nothing else
For the finishing touch restart your server
For Multile local domain add another section of code into httpd-vhosts.conf
<VirtualHost myWebsite.local>
DocumentRoot "C:/wamp/www/php-bugs2/"
ServerName php-bugs.local2
ServerAlias php-bugs.local2
<Directory "C:/wamp/www/php-bugs2/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and add your host into host file 127.0.0.1 php-bugs.local2

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)

Rails 3 Deploy: Multiple rails apps single domain error: No such file or directory - config/environment.rb

Yesterday, I bought a server on Linode. I setup Apache, RVM, Rails, MySQL and have got a single rails app hosted on a domain, following a nice guide from http://library.linode.com/frameworks/ruby-on-rails-apache/ubuntu-10.04-lucid. It also explains how to put multiple rails apps on the same domain, however when I try, I get an error when I access my domain our-portal.com/adm :
No such file or directory - config/environment.rb
Application root: /srv/www/our-portal.com/public_html
Somethings wrong here... anyone have any ideas? I am able to host a single app just fine, but not multiple... Here is my Virtual Host settings
<VirtualHost *:80>
ServerAdmin webmaster#our-portal.com
ServerName our-portal.com
ServerAlias www.our-portal.com
DocumentRoot /srv/www/our-portal.com/public_html/
RailsBaseURI /adm
RailsBaseURI /matrix
ErrorLog /srv/www/our-portal.com/logs/error.log
CustomLog /srv/www/our-portal.com/logs/access.log combined
</VirtualHost>
My applications path is in /srv/www/our-portal.com/adm/ and I linked using
ln -s /srv/www/our-portal.com/adm/public/ /srv/www/our-portal.com/public_html/adm/
ln -s /srv/www/our-portal.com/matrix/public/ /srv/www/our-portal.com/public_html/matrix/
Try by setting the DocumentRoot to the public folder of your application:
DocumentRoot /srv/www/our-portal.org/app/public
I got it working, these are the changes I made.
<VirtualHost *:80>
ServerAdmin webmaster#our-portal.com
ServerName our-portal.com
ServerAlias www.our-portal.com
DocumentRoot /srv/www/our-portal.com/public_html
<Directory /srv/www/our-portal.com/public_html>
Allow from all
</Directory>
RailsBaseURI /adm
RailsBaseURI /matrix
<Directory /srv/www/our-portal.com/public_html/adm>
Options -MultiViews
</Directory>
<Directory /srv/www/our-portal.com/public_html/matrix>
Options -MultiViews
</Directory>
ErrorLog /srv/www/our-portal.com/logs/error.log
CustomLog /srv/www/our-portal.com/logs/access.log combined
</VirtualHost>
I also believe my links were not created correctly. It helped to type
ln -s
and double-click tab (without executing the command) to look at the correct way Unix handles the path for this function. My links looked like this
ln -s /srv/www/our-portal.com/adm/public/ our-portal.com/public_html/adm
ln -s /srv/www/our-portal.com/sitedb-pro/public/ our-portal.com/public_html/matrix
Notice the difference from my old links. Using double-click tab I was able to reference these folders correctly.

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.

Frontend pages giving 404 with symfony and apostrophe

I thinks this question might be on the edge of having to go on serverfault. However, as I'm not sure about the cause of the problem, I'll ask the question here.
I Have a Symfony installation with 2 apps: frontend and backend
On the frontend I run apostrophe cms and in the backend I have some modules from the doctrine admin generator.
Everything works fine local. However, on my production server, every frontend page after http://mydomain.com/ gives a 404 error. The weird thing is that http://mydomain.com/backend/ works fine. I'm not sure if its my apache config (seeing as /backend/ does work) but I'll paste it here, just to be sure. This is what I have in sites-available/default:
<VirtualHost *:80>
DocumentRoot "/mysfproject/web"
DirectoryIndex index.php
<Directory "/mysfproject/web">
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Allow from All
</Directory>
ErrorLog /var/log/apache2/error.log
Alias /sf /mysfproject/lib/vendor/symfony/data/web/sf
<Directory "/mysfproject/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Any help would be greatly appreciated!
Turns out mod_rewrite was disabled. Fixed it by doing sudo a2enmod rewrite

Resources