2007年5月9日星期三

apache支持rails

搞了半天终于知道该怎么用fastcgi结合apache支持rails运行了,不过感觉运行起来效果不怎么好,还不如lighttpd方便哈,把主要配置记录一下,方便今后自己用到: 1、下载RubyForApache-1.3.1.exe,注意选好目录,并且安装的时候只装mod_fastcgi,而千万不要装mod_ruby和mysql.so。 2、编辑apache的httpd.conf文件,找到:

#LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule fastcgi_module modules/mod_fastcgi.so

两行,将#都去掉,并且加入代码:

AddHandler fastcgi-script .fcgi

3、继续加入代码:

ServerName rails
DocumentRoot G:/depot/public

Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny

4、编辑c:\windows\system32\drivers\etc\host文件,在后面加入: 127.0.0.1 rails 这里要注意的是中间的不是空格,而是一个tab键哈 5、编辑public文件夹中的.htaccess文件,找到RewriteRule ^$ index.html [QSA]一行,将这四行改为:

RewriteRule ^$ index.html [QSA]
RewriteBase /dispatch.fcgi#加入这行
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]#修改为.fcgi哈

下面我们就可以打开http://rails:8080/来运行rails程序了哈。至于其他的比如设置超时什么的就留给大家自己去做了哈,可以参考其他的一些文章来进行配置,在这里我主要就是想演示一下怎么让它运行起来。

2007年5月1日星期二

开通blog

blog顺利开通中```