apache+fastcgi+ruby+rails 安装指南

 

准备工作

1,从 http://archive.apache.org/dist/httpd/下载 apache1.3.xx
2,从 http://www.fastcgi.com/dist/下载fcgi-xx.tar.gz,mod_fastcgi-xx.tar.gz
3,从 http://rubyforge.org/frs/?group_id=926&release_id=5851 下载 ruby-fcgi-xx.tar.gz

安装apache

tar -zxvf apache_1.3.36.tar.gz
cd apache_1.3.36
./configure --prefix=/usr/local/apache1.3.36 --enable-module=so --enable-module=env --enable-module=setenvif --enable-module=rewrite --enable-module=proxy
make
make install

安装mod_fastcgi


tar -zxvf mod_fastcgi-SNAP-0404142202.tar.gz
cd mod_fastcgi-SNAP-0404142202
/usr/local/apache1.3.36/bin/apxs -o mod_fastcgi.so -c *.c
/usr/local/apache1.3.36/bin/apxs -i -a -n fastcgi mod_fastcgi.so

这时候会在apache的httpd.conf里加入
LoadModule fastcgi_module     libexec/mod_fastcgi.so

安装fastcgi


tar -zxvf fcgi-2.4.1-SNAP-0311112127.tar.gz
cd fcgi-2.4.1-SNAP-0311112127
make
make install

安装ruby-fcgi


tar -zxvf ruby-fcgi-0.8.7.tar.gz
cd ruby-fcgi-0.8.7
ruby install.rb config
ruby install.rb setup
ruby install.rb install

修改 .htaccess


vi rails-application目录/public/.htaccess
将 RewriteRule ^(.*)$ dispatch.cgi [QSA,L] 改成
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
然后保存

修改apche的httpd.conf

在httpd.conf里加入下面两个指令

#配置fastcgi-server
<IfModule mod_fastcgi.c>
   FastCgiIpcDir /tmp/fcgi_ipc
   FastCgiServer /your-rails-app-dir/public/dispatch.fcgi -initial-env RAILS_ENV=development -processes 15 -idle-timeout 60
</IfModule>

#配置域名
<VirtualHost *:80>
  ServerName your-app-domain-name
  DocumentRoot /your-rails-app-dir/public #rails应用目录
  ErrorLog /data/log/rails.log #日志目录,确保可写
  <Directory /your-rails-app-dir/public>
    Options ExecCGI FollowSymLinks
    AllowOverride all
    Allow from all
    Order allow,deny
  </Directory>
</VirtualHost>


现在,就可以通过域名 http://your-app-domain-name (代表你的域名)访问rails应用了


 

你可能感兴趣的:(apache,工作,Module,Ruby,Rails,.htaccess)