I saw the following posting from back in December but I need some help understanding it. I''m no Apache expert so once I''m using this .conf file what does my app directory structure look like. At this point I don''t have a public dir in /var/www/rails so I''ll create one but then what goes in it? ----------------------------------------------------------------------------------------- Hello, I posted a page with a apache configuration to do that on the rails wiki, but unfortunately it got lost. I''m attaching it now, because the lines are a bit uncomfortably long for email. With this method you can do what you want just fine, and avoid per directory rewriting which is a hack, really. Of course you have to take care with relative URLs in the application, but resource sharing is much easier. Cheers, Han Holl -------------- next part -------------- # Directory based Rails apache configuration without per directory mod_rewrite # Two global replaces (in the right order) should suffice to relocate # This file can be dropped in /etc/httpd/conf.d as rails.conf -- no need to touch httpd.conf # Can co-exist with other parts of a website and other rails applications alias /rails /var/www/rails/public <IfModule !mod_fastcgi.c> LoadModule fastcgi_module modules/mod_fastcgi.so </IfModule> FastCgiServer /var/www/rails/public/dispatch.fcgi -socket /var/tmp/rails.socket RewriteLog /var/log/rewrite.log RewriteLogLevel 5 RewriteEngine On # Skip rest of rewrite if url doesn''t start with /rails # Yes, S=14 is rather fragile, but it''s the best we can do at this time RewriteCond %{REQUEST_URI} !^/rails/? RewriteRule .* - [S=15] # Skip rest of rewrite if there is no controller # Use PT to let mod_alias do the remapping RewriteCond %{REQUEST_URI} !^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ RewriteRule .* - [S=14,PT] RewriteCond %{REQUEST_URI} ^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ RewriteCond /var/www/rails/public/../app/controllers/%2_controller.rb !-f RewriteRule .* - [S=13,PT] # Remove /rails from URL RewriteRule ^/rails(.*) $1 # Force fcgi RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2&id=$3 [L,QSA] RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2 [L,QSA] RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/?$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=sql [L,QSA] RewriteRule ^/fcgi.* /var/www/rails/public/dispatch.fcgi?controller=dps&action=sql [L,QSA] # Force mod_ruby RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.rb?controller=$1&action=$2&id=$3 [L,QSA] RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.rb?controller=$1&action=$2 [L,QSA] RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/?$ /var/www/rails/public/dispatch.rb?controller=$1&action=sql [L,QSA] RewriteRule ^/mruby.* /var/www/rails/public/dispatch.rb?controller=dps&action=sql [L,QSA] # Default rewriting rules. Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby RewriteRule ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.cgi?controller=$1&action=$2&id=$3 [L,QSA] RewriteRule ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.cgi?controller=$1&action=$2 [L,QSA] RewriteRule ^/([-_a-zA-Z0-9]+)/$ /var/www/rails/public/dispatch.cgi?controller=$1&action=sql [L,QSA] RewriteRule .* /var/www/rails/public/dispatch.cgi?controller=sql&action=show [L,QSA] <Directory /var/www/rails/public> AllowOverride none Order allow,deny Allow from all # General Apache options AddHandler fastcgi-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI # Remember to set RubySafeLevel 0 in httpd.conf <IfModule mod_ruby.c> RubySafeLevel 0 RubyRequire apache/ruby-run <Files dispatch.rb> SetHandler ruby-object RubyHandler Apache::RubyRun.instance </Files> </IfModule> # You can also point these error messages to a controller/action ErrorDocument 500 /rails/500.html ErrorDocument 404 /rails/404.html </Directory> _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Is anyone using this configuration? What are you doing to run multiple app on one Apache instance? On 10/7/05, Xavier Toth <txtoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I saw the following posting from back in December but I need some help understanding it. > I''m no Apache expert so once I''m using this .conf file what does my app directory structure look like. At > this point I don''t have a public dir in /var/www/rails so I''ll create one but then what goes in it? > > > ----------------------------------------------------------------------------------------- > > Hello, > > I posted a page with a apache configuration to do that on the rails wiki, but > unfortunately it got lost. > > I''m attaching it now, because the lines are a bit uncomfortably long for > email. > With this method you can do what you want just fine, and avoid per directory > rewriting which is a hack, really. > Of course you have to take care with relative URLs in the application, but > > resource sharing is much easier. > > Cheers, > > Han Holl > -------------- next part -------------- > # Directory based Rails apache configuration without per directory mod_rewrite > # Two global replaces (in the right order) should suffice to relocate > > # This file can be dropped in /etc/httpd/conf.d as rails.conf -- no need to touch httpd.conf > # Can co-exist with other parts of a website and other rails applications > alias /rails /var/www/rails/public > > <IfModule !mod_fastcgi.c> > > LoadModule fastcgi_module modules/mod_fastcgi.so > </IfModule> > FastCgiServer /var/www/rails/public/dispatch.fcgi -socket /var/tmp/rails.socket > RewriteLog /var/log/rewrite.log > RewriteLogLevel 5 > RewriteEngine On > > > # Skip rest of rewrite if url doesn''t start with /rails > # Yes, S=14 is rather fragile, but it''s the best we can do at this time > RewriteCond %{REQUEST_URI} !^/rails/? > RewriteRule .* - [S=15] > # Skip rest of rewrite if there is no controller > > # Use PT to let mod_alias do the remapping > RewriteCond %{REQUEST_URI} !^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ > RewriteRule .* - [S=14,PT] > RewriteCond %{REQUEST_URI} ^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ > > RewriteCond /var/www/rails/public/../app/controllers/%2_controller.rb !-f > RewriteRule .* - [S=13,PT] > # Remove /rails from URL > RewriteRule ^/rails(.*) $1 > # Force fcgi > RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2&id=$3 [L,QSA] > > RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2 [L,QSA] > RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/?$ /var/www/rails/public/dispatch.fcgi?controller=$1&action=sql [L,QSA] > > RewriteRule ^/fcgi.* /var/www/rails/public/dispatch.fcgi?controller=dps&action=sql [L,QSA] > > # Force mod_ruby > RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.rb?controller=$1&action=$2&id=$3 [L,QSA] > > RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.rb?controller=$1&action=$2 [L,QSA] > RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/?$ /var/www/rails/public/dispatch.rb?controller=$1&action=sql [L,QSA] > > RewriteRule ^/mruby.* /var/www/rails/public/dispatch.rb?controller=dps&action=sql [L,QSA] > > # Default rewriting rules. Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby > > RewriteRule ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ /var/www/rails/public/dispatch.cgi?controller=$1&action=$2&id=$3 [L,QSA] > RewriteRule ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /var/www/rails/public/dispatch.cgi?controller=$1&action=$2 [L,QSA] > > RewriteRule ^/([-_a-zA-Z0-9]+)/$ /var/www/rails/public/dispatch.cgi?controller=$1&action=sql [L,QSA] > RewriteRule .* /var/www/rails/public/dispatch.cgi?controller=sql&action=show [L,QSA] > > > <Directory /var/www/rails/public> > > AllowOverride none > Order allow,deny > Allow from all > > # General Apache options > AddHandler fastcgi-script .fcgi > AddHandler cgi-script .cgi > Options +FollowSymLinks +ExecCGI > > # Remember to set RubySafeLevel 0 in > httpd.conf > <IfModule mod_ruby.c> > RubySafeLevel 0 > RubyRequire apache/ruby-run > <Files dispatch.rb> > SetHandler ruby-object > RubyHandler Apache::RubyRun.instance > </Files> > > </IfModule> > > # You can also point these error messages to a controller/action > ErrorDocument 500 /rails/500.html > ErrorDocument 404 /rails/404.html > </Directory> > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This method seems to work well: http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnCpanel -- Joe Clarke RailsPlayground.com On 10/8/05, Xavier Toth <txtoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is anyone using this configuration? What are you doing to run multiple app > on one Apache instance? > > > On 10/7/05, Xavier Toth < txtoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I saw the following posting from back in December but I need some help > understanding it. > > > > I''m no Apache expert so once I''m using this .conf file what does my app > directory structure look like. At > > this point I don''t have a public dir in /var/www/rails so I''ll create one > but then what goes in it? > > > > > > > > > ----------------------------------------------------------------------------------------- > > > > Hello, > > > > I posted a page with a apache configuration to do that on the rails wiki, > but > > unfortunately it got lost. > > > > > > I''m attaching it now, because the lines are a bit uncomfortably long for > > email. > > With this method you can do what you want just fine, and avoid per > directory > > rewriting which is a hack, really. > > Of course you have to take care with relative URLs in the application, but > > > > > > resource sharing is much easier. > > > > Cheers, > > > > Han Holl > > -------------- next part -------------- > > # Directory based Rails apache configuration without per directory > mod_rewrite > > # Two global replaces (in the right order) should suffice to relocate > > > > > > # This file can be dropped in /etc/httpd/conf.d as rails.conf -- no need > to touch httpd.conf > > # Can co-exist with other parts of a website and other rails applications > > alias /rails /var/www/rails/public > > > > > > <IfModule !mod_fastcgi.c> > > > > LoadModule fastcgi_module modules/mod_fastcgi.so > > </IfModule> > > FastCgiServer /var/www/rails/public/dispatch.fcgi -socket > /var/tmp/rails.socket > > RewriteLog /var/log/rewrite.log > > > > RewriteLogLevel 5 > > RewriteEngine On > > > > > > # Skip rest of rewrite if url doesn''t start with /rails > > # Yes, S=14 is rather fragile, but it''s the best we can do at this time > > RewriteCond %{REQUEST_URI} !^/rails/? > > > > RewriteRule .* - [S=15] > > # Skip rest of rewrite if there is no controller > > > > # Use PT to let mod_alias do the remapping > > RewriteCond %{REQUEST_URI} > !^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ > > RewriteRule .* - [S=14,PT] > > > > RewriteCond %{REQUEST_URI} > ^/rails(/fcgi/|/mruby/|/)([-_a-zA-Z0-9]+)/ > > > > RewriteCond > /var/www/rails/public/../app/controllers/%2_controller.rb > !-f > > RewriteRule .* - [S=13,PT] > > # Remove /rails from URL > > RewriteRule ^/rails(.*) $1 > > > > # Force fcgi > > RewriteRule > ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ > /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2&id=$3 > [L,QSA] > > > > RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ > /var/www/rails/public/dispatch.fcgi?controller=$1&action=$2 > [L,QSA] > > > > RewriteRule ^/fcgi/([-_a-zA-Z0-9]+)/?$ > /var/www/rails/public/dispatch.fcgi?controller=$1&action=sql > [L,QSA] > > > > RewriteRule ^/fcgi.* > /var/www/rails/public/dispatch.fcgi?controller=dps&action=sql > [L,QSA] > > > > > > # Force mod_ruby > > RewriteRule > ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ > /var/www/rails/public/dispatch.rb?controller=$1&action=$2&id=$3 > [L,QSA] > > > > RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ > /var/www/rails/public/dispatch.rb?controller=$1&action=$2 > [L,QSA] > > > > RewriteRule ^/mruby/([-_a-zA-Z0-9]+)/?$ > /var/www/rails/public/dispatch.rb?controller=$1&action=sql > [L,QSA] > > > > RewriteRule ^/mruby.* > /var/www/rails/public/dispatch.rb?controller=dps&action=sql > [L,QSA] > > > > > > # Default rewriting rules. Change extension from .cgi to .fcgi to switch > to FCGI and to .rb to switch to mod_ruby > > > > RewriteRule > ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9.]+)$ > /var/www/rails/public/dispatch.cgi?controller=$1&action=$2&id=$3 > [L,QSA] > > > > RewriteRule ^/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ > /var/www/rails/public/dispatch.cgi?controller=$1&action=$2 > [L,QSA] > > > > RewriteRule ^/([-_a-zA-Z0-9]+)/$ > /var/www/rails/public/dispatch.cgi?controller=$1&action=sql > [L,QSA] > > > > RewriteRule .* > /var/www/rails/public/dispatch.cgi?controller=sql&action=show > [L,QSA] > > > > > > <Directory /var/www/rails/public> > > > > AllowOverride none > > Order allow,deny > > Allow from all > > > > > > # General Apache options > > AddHandler fastcgi-script .fcgi > > AddHandler cgi-script .cgi > > Options +FollowSymLinks +ExecCGI > > > > # Remember to set RubySafeLevel 0 in > > httpd.conf > > <IfModule mod_ruby.c> > > > > RubySafeLevel 0 > > RubyRequire apache/ruby-run > > <Files dispatch.rb> > > SetHandler ruby-object > > RubyHandler Apache::RubyRun.instance > > </Files> > > > > </IfModule> > > > > > > # You can also point these error messages to a controller/action > > ErrorDocument 500 /rails/500.html > > ErrorDocument 404 /rails/404.html > > </Directory> > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >