«  (ZT)The World's Mo...   |   Blog首页   |   New Features in JS... »

2006/03/15

一篇 Linux 环境下安装 apache 2.0.x + ruby + rails + fastcgi 很具体的向导

原文网址:

http://wiki.rubyonrails.com/rails/pages/HowtoSetupApacheWithFastCGIAndRubyBindings

 

How to install Apache, Ruby, RubyGems, Rails, and FastCGI? under Linux

  1. Become root and go to a directory to work in
    		su rootcd /usr/local/src
    		
  2. Download all of the needed files. These versions may be out of date, so you might want to go find the latest.
    		wget http://xyz.lcs.mit.edu/ruby/ruby-1.8.2.tar.gzwget http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgzwget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gzwget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gzwget http://mirrors.ccs.neu.edu/Apache/dist/httpd/httpd-2.0.53.tar.gz
    		
  3. Install Ruby
    		tar -zxvf ruby-1.8.2.tar.gzcd ruby-1.8.2./configuremakemake testmake installcd ..
    		
  4. Install Ruby Gems
    		tar -zxvf rubygems-0.8.10.tgzcd rubygems-0.8.10ruby setup.rb    :Install required dependency rake? [Yn]  yInstall required dependency activesupport? [Yn]  yInstall required dependency activerecord? [Yn]  yInstall required dependency actionpack? [Yn]  yInstall required dependency actionmailer? [Yn]  yInstall required dependency actionwebservice? [Yn]  y    :cd ..
    		
  5. Install Apache (if needed—if you have an existing Apache installation & know what you are doing this step can be skipped)
    		tar -zxvf httpd-2.0.53.tar.gzcd httpd-2.0.53./configure --enable-rewrite --enable-cgimakemake installcd ..
    		
  6. Install FastCGI?
    		tar -zxvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0./configuremakemake install
    		
  7. Install mod_fastcgi for Apache (note that this assumes you are using Apache-2.x, etc.; if you are using Apache 1.3, DSOs, etc. read the INSTALL file.
  8. Install Rails
    		gem install rails
    		
  9. Install the fcgi gem
    		gem install fcgi
    		

    On FreeBSD, If you receive “ERROR: While executing gem” stating “checking for fcgiapp.h… no” then you will have to run the gem install with alternate syntax:
    		gem install fcgi -- --with-fcgi-include=/usr/local/include --with-fcgi-lib=/usr/local/lib
    		
  10. Edit your Apache configuration (typically found somewhere like /usr/local/apache2/conf/httpd.conf or /etc/httpd/conf/httpd.conf) and add these lines:
    		<Directory /var/www/>    AllowOverride all</Directory>LoadModule fastcgi_module modules/mod_fastcgi.soAddHandler fastcgi-script .fcgi<VirtualHost *:80>    ServerAdmin webmaster@example.com    DocumentRoot /var/www/rails/testapp/public    ServerName www.example.com    ErrorLog /var/log/httpd/testapp-error_log    CustomLog /var/log/httpd/testapp-access_log common    Options Indexes ExecCGI FollowSymLinks    RewriteEngine On</VirtualHost>
    		
  11. Start Apache
    		/usr/local/apache2/bin/apachectl start
    		
  12. Go to http://www.example.com and see the Rails welcome page.
  13. Set up a database for Rails in database.yml (or see HowToUseRailsWithoutADatabase).
  14. Create a simple controller for testing Rails
    		cd /var/www/rails/testapp/publicrm index.htmlcd ..script/generate controller home index
    		
  15. Go to www.example.com/home/index and see a default view, running with normal cgi.
  16. Enable FastCGI?
    1. Edit /var/www/rails/testapp/public/.htaccess and change dispatch.*cgi* to dispatch.*fcgi*
    2. Edit /var/www/rails/testapp/public/dispatch.fcgi (in rails 0.13.1 this is within the rails installation: lib/fcgi_handler.rb) and change
      			require 'fcgi'
      			

      to
      			require 'rubygems'require_gem 'fcgi'
      			
  17. Go to www.example.com/home/index and see a default view again, but with fcgi

Troubleshooting Suggestions
Make sure that you delete any ruby session files in your /tmp directory before switching to dispatch.fcgi. If you tested with cgi, there might be some with different permission that what apache (fastcgi) can read and will cause issue.

If you want to see if fastcgi is working with ruby, try pasting the following into test.fcgi (in your rails/public dir). You will need to make sure the file has 755 permissions (chmod 755 test.fcgi).

			#!/usr/local/bin/rubyrequire 'cgi'require 'rubygems'require_gem 'fcgi' FCGI.each_cgi do |cgi|    content = ''    env = []    cgi.env_table.each do |k,v|      env << [k,v]    end    env.sort!    env.each do |k,v|      content << %Q(#{k} => #{v}<br>\n)    end    cgi.out{content} end

The above test was working but I didn´t get the dispatcher running under apache2 (self built) until i changed the dependencies of rails-0.14.1/lib/fcgi_handler.rb to:

			require 'cgi'require 'rubygems'require_gem 'fcgi'require 'logger'require 'dispatcher'require 'rbconfig'class RailsFCGIHandler...

 

I don´t know why this is like this (why the dependencies in the dispatcher should be wrong) but it helped.


I’ve been bitten by two things with the Apache configuration: I had MultiViews on, and I was redirecting /some/url.html to /some/url because I don’t want file extensions in my URLs. The second rule causes endless redirect looping with standard Rails’ .htaccess, and MultiViews interferes badly with Rails’ caching. So, keep MultiViews off, and be careful with those redirects. —Matijs van Zuijlen



I have yet to get Apache fcgi working Windows XP SP2. I’ve got Apache working with Rails but it’s slow as mud. I’ve downloaded all the software that I can find and put in the http.conf file the recommended Apache configuration but can’t tell if fcgi is working or not.

Does anyone have a simple step by step recipe to get Apache (v2) on Windows XP Prof running fcgi? I found a test page for Rails but it doesn’t render the link

			<html>  <head>    <title>Ajax Demo</title>    <%= javascript_include_tag "prototype" %>  </head>  <body>    <h1>What time is it?</h1>    <div id="time_div">      I don't have the time, but      <%= link_to_remote( "click here",                         :update => "time_div",                         :url =>{ :action => :say_when }) %>      and I will look it up.    </div>  </body></html>
			

 

I get the page minus the “click here” link????


For anyone trying to get fastcgi working after installing the gem version of the ruby fastcgi lib, I found uninstalling it, then loading the library version and building it, fixed all problems. Download from here http://raa.ruby-lang.org/project/fcgi/ read the README and build and install, and fastcgi starts working.

阿涂 发表于 2006-03-15 20:12  阅读(2572) 评论( 5) 引用( 6) 技术
所有人可见

  • 收藏文章:
  • save at del.icio.us
  • save at digg
  • save at my yahoo
  • save at blinklist
  • save at furl
  • save at simpy
  • save at blogmarks
  • submit at reddit
  • save at spurl
  • save at shadows
  • save at rawsugar
  • save at bloglines

引用

http://www.uuzone.com/app/trackBack.do?type=blog&trackBackID=87872

gay bear
ball torturesaint sylviahardcore blondenude boys

Posted bygay bearat 2006-11-15 18:55

girls smoking
celebrity upskirtpictures pregnantboys nudeporn star

Posted bygirls smokingat 2006-11-15 16:21

cocks sucking
nude girlfriendgay boyblack bootysex mature

Posted bycocks suckingat 2006-11-15 15:24

cheerleader pics
porn star mpegteen upskirtspantyhose photointerracial mpeg

Posted bycheerleader picsat 2006-11-15 06:21

sex torture
sex peeteen bdsmindian picturesnikki tyler mpeg

Posted bysex tortureat 2006-11-15 04:32

crossdressing pictures
gay teen sexsexy brunettegangbangsteens site

Posted bycrossdressing picturesat 2006-11-15 03:08

相关内容
更多..

回复列表每两分钟自动刷新一次,想立即刷新吗?点击这里

您的浏览器可能不支持Frame, 优友地带需要使用Frame才能显示正常页面!