我---7号斋主人

已婚
爱老婆
I wanna be a happy fish...

星期四, 十月 12, 2006

婚纱照






昨天把婚纱照拷回来了。
PO几张上来先。

星期二, 十月 10, 2006

fastcgi+apache的重要资料

摘自:
http://wiki.rubyonrails.com/rails/pages/Fast+CGI+and+Apache2+for+Windows+XP

Fast CGI and Apache2 for Windows XP
Home Page | All Pages | Recently Revised | Feed
Rails Prod Win

If you want to get Rails on XP using Apache 2.2 + FastCGI/SCGI support with the MySQL C binding download the Rails Prod Win setup kit and follow the instructions…you should be up and running in no time.
http://sourceforge.net/projects/rails-prod-win/
Other Method (longer…)

This has been a pretty big thorn in my side (and it seems others have gone through the same headaches and all the info out there is just plain wrong, wrong, wrong) and I’ve finally made it work for me, so I thought I’d share.
Things you’ll need

(This is my development machine, though I suspect this should work under different configurations)

* Windows XP SP2
* Apache 2.0.54
* MySQL
* Ruby one-click installer
* FastCGI 2.4.2
* and Ruby for Apache
* Rails 0.13.1

Initial intallation

* Install the basic stuff: Apache, \MySQL, Ruby, gem install rails. Easy.

* Rename mod_fastcgi-2.4.2-AP20.dll to mod_fastcgi.dll (just to make life easy), and copy it to the Apache modules folder (default is c:\programs files\Apache Group\Apache2\modules).

* Install Ruby for Apache. Important: only install mod_fastcgi. Do NOT install mod_ruby or mysql.so because these directions will not work with them.
Note also that the install may complain that it cannot open c:\xppro\system32\msvcp71.dll for writing. Just rename it and retry.

* Create your Rails app. In the console do something like


rails yourappname

Configure Apache

Now you’ll need to configure Apache. Don’t worry, this is easy-easy. Go to your start menu, find the Apache programs group. In there you’ll see a sub-group called something like “Configure Apache Server”. Click on “Edit the Apache httpd.conf Configuration File”

Now you’re looking at a text file with all kinds of confusing stuff, right? Look for a line that looks like


#LoadModule rewrite_module modules/mod_rewrite.so

and change it to


LoadModule rewrite_module modules/mod_rewrite.so


(i.e., uncomment the line)

Then add a new line like this


LoadModule fastcgi_module modules/mod_fastcgi.dll

If you use Apache 1.3.x you also need to make corresponding changes in the AddModule section below the LoadModule section.

Find the line


#AddModule mod_rewrite.c

and uncomment that:


AddModule mod_rewrite.c

Then add a new line:


AddModule mod_fastcgi.c

Now you need to set up a root directory for your application. Look for a line that starts with DocumentRoot and change the path to your Rails application folder.

Next look for a line that starts with Directory and change that path to your Rails application folder (same as above)

(Remember for both paths above to use forward slashes not the normal Windows backslashes)

Almost done with Apache configuration…

(see Fast CGI and Apache2 for Windows without VirtualHosts for an alternative to using VirtualHost directives)

at the bottom of the file add this:



ServerName rails
DocumentRoot "c:/path/to/your/rails/app/public"

Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi



(set paths above accordingly)
Configure your Rails app

Go to the public folder in your Rails application and open .htaccess

Look for the rewrite rule:


RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

and change it to:


RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Comment out the Apache section in your .htaccess as you’ve already referenced these in your Apache httpd.conf file earlier.

Open dispatch.fcgi and change the first line to


#!c:/ruby/bin/ruby

to accomodate Windows
Add a new host

Last little bit…

Open up your host file (c:\windows\system32\drivers\etc\host)

and add this line:


127.0.0.1 YourRailsAppName

Cool, you’re done

Note from porter.ea:
One additional edit that I found necessary was to add ”#!c:/pathto/rubybin/rubyw” (note the “w”) at the top of the “C:\appname\public\dispatch.fcgi” file.

This was purely a guess on my part based on perusal of the /ruby/bin directory, but it caused my Apache to go from hanging for a long time, then displaying: “Application error Rails application failed to start properly”, to displaying the correct output in better time.
:End Note

Now start Apache, open a browser and type in ”\YourRailsAppName”

you should load the default Welcome to Rails page with blazing \FastCGI speeds.

Like I said easy-easy.
Another Note:

if the Above instructions still do not work for you, please try reversing the slashes:


#!c:\ruby\bin\ruby

It has worked for me.
Additional Notes

1) You might need to add the following line to httpd.conf (particularly on a dev machine)

IfModule mod_fastcgi.c>
FastCgiServer {rails_app_dir}/public/dispatch.fcgi\
-initial-env RAILS_ENV=development \
-processes 3 -idle-timeout 120
/IfModule


This prevents premature timeouts and limits the FASTCgi processes to 3.

2) If using mysql and get ‘uninitialize constant mysql’ error, you may have to copy libmysql.dll to ruby bin (e.g. c:\ruby\bin).

3) Take special care to run your rails-application in “production”-mode. See environment.rb (msc)
Another Note about apache port

If you are on windows, you may probably use the virtual host with a non-80 port (since port 80 used by IIS defaultly). Thus don’t forget add “Listen ${port_number}” in the httpd.conf, otherwise you will never see the rails welcome page.
I forgot this and it wasted a lot of my time to find the problem.
Questions

Does anyone know how I could setup multiple rails apps on the same machine using virtual hosts?

让rails在apache上跑起来

同PHP设置VirtualHost一样,在httpd.conf中添加一段代码。
我的rails项目文件夹为:D:\App_ror\HA\
在此基础上,我的VirtualHost设置如下:

<VirtualHost *:80>
ServerName ha
DocumentRoot "D:/App_ror/HA/public"
AliasMatch ^/([^/]*)(.*) "D:/App_ror/$1/public$2"
<Directory "D:/App_ror/HA/public">
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fcgid-script .fcgi
</Directory>
</VirtualHost>

接着,修改rails项目本身的一些配置。
1、修改.htaccess,找到
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

改为
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

2、修改C:\WINDOWS\system32\drivers\etc下hosts文件,在
127.0.0.1 localhost

后加一行
127.0.0.1 ha


即可,祝顺,哈哈。

Apache+FastCGI+Rails(原)

刚才发了一篇网摘的关于apache+fastcgi+rails在windows下的配置方法,如下:

Apache+FastCGI+Rails(摘)

按照这个方法配置,必须是针对apache2.0版本的,因为mod_fastcgi.so的当前版本还没有支持apache2.2.x的,所以,如果使用apache2.2.x版本,当启动apache的时候始终是会有“the requested operation has failed!”的对话框。

所以mod_fcgid被我找到了,可以看看有中文的介绍。
mod_fcgid.so下载地址。

对于曾经尝试过配置apache2.2.x+fastcgi的人来说,那么配置起来是一样的。只是名称不同:
1、复制mod_fcgid.so到apache目录\modules下;
2、在httpd.conf中找到
#LoadModule rewrite_module modules/mod_rewrite.so

改成
LoadModule rewrite_module modules/mod_rewrite.so

在后面加一段代码
<ifmodule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</ifmodule>

重启动apache就OK了。

今天在搞这个玩意的时候,还发现一个评价颇高的东西:instantrails,下面有些信息。
评论---wiki---下载

有时间看看。

ror似乎越来越有看头了,只是1个月不到的时间没有去了解相关信息,已经有这么多东西相继出现。

拭目以待...

Apache+FastCGI+Rails(摘)

CSDN上的一篇关于配置rails在Apache+FastCGI得文章,看过很多篇,没有存档,也是因为自己按照文章上讲的没有配置成功,希望这篇有用,存之。
-----------------------------

1 安装Ruby

略…

Ruby的版本要是1.8.2的,Rails 0.13中用到了一些老版本Ruby中没有的特性,所以最好还是用新一点的。我的机器上:C:\>ruby -v : ruby 1.8.2 (2004-12-25) [i386-mswin32]

2 安装rubygems

windows下的ruby installer自带了rubygems,如果安装时没选,到此处下载rubygems

http://rubyforge.org/projects/rubygems/

解压后运行C:\>rubygems-0.8.10\ruby setup.rb,查看是否安装好,C:\>gem -v : 0.8.10

3 安装Rails

C:\>gem install rails --include-dependencies

会安装Rails以及其依赖的其它gem

因为是remote安装,可能会比较慢,也可以先下到本地来安装(http://gems.rubyforge.org/gems/)。命令执行完后,看看装了哪些gem:

C:>gem list

actionmailer (1.0.1)
Service layer for easy email delivery and testing.

actionpack (1.9.1)
Web-flow and rendering framework putting the VC in MVC.

actionwebservice (0.8.1)
Web service support for Action Pack.

activerecord (1.11.1)
Implements the ActiveRecord pattern for ORM.

activesupport (1.1.1)
Support and utility classes used by the Rails framework.

rails (0.13.1)
Web-application framework with template engine, control-flow layer,
and ORM.

rake (0.5.4)
Ruby based make-like utility.

4 安装FastCGI

到此处下载RubyForApache

http://rubyforge.org/projects/rubyforapache

RubyForApache 包含了mod_fastcgi和mod_ruby,我们只需要用到mod_fastcgi。安装时要选好Apache的目录,installer会在选定 的目录/modules下面放入mod_fastcgi,所以如果后面Apache找不到这个模块,就看看是否安装正确了。

5 配置Apache

Apache的安装就不说了,我的版本是2.0.48 。

打开httpd.conf文件,首先是加载一些模块:

LoadModule rewrite_module modules/mod_rewrite.so # <- 重要

LoadModule fastcgi_module modules/mod_fastcgi.so


AddHandler fastcgi-script .fcgi

#下面这句话很重要,设置超时时间,因为rails启动时间比较长,如果太短了,容易超时,导致fastcgi反覆启动ruby进程,根据你的机器配置来设
FastCgiConfig -restart-delay 120 -idle-timeout 150 -appConnTimeout 100 -init-start-delay 100 -startDelay 100

因为我还要用到PHP,所以做了一个Virtual Host

NameVirtualHost *:8080 #端口号根据你自己的改,我的80被IIS占了


ServerName rails
# 随便起的一个名字

#下面设置的是放置你的rails程序的位置,我是放在e:/learnruby目录下的

#下面这句话的是alias所有的形如"/app/controller/action"的路径为实际路径e:/learnruby/app/public/controller/action

#rails应用程序app目录下面的public目录就是给http server用的,alias之后,Apache才能找到rails的dispatch.fcgi文件

AliasMatch ^/([^/]*)(.*) "e:/learnruby/$1/public$2"

#这里需要设置e:/learnruby目录具有ExecCGI FollowSymLinks选项

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

RewriteEngine on
RewriteLogLevel 0

保存之后重启Apache。

还要再编辑rails应用程序目录下的public/.htaccess文件,假设应用程序的名字为demo(可以用

E:\learnruby>rails demo命令在e:\learnruby下新建一个空的应用)

那么要加入一句话:
RewriteBase /demo

为了能使用fastcgi,还要将RewriteRule ^(.*)$ dispatch.cgi [QSA,L]注释掉,并去掉RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]的注释

最后看起来大概会是这样:

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

6 测试

为了能访问到rails虚拟主机,还要在C:\WINDOWS\system32\drivers\etc\hosts文件中加入

127.0.0.1 rails

打开浏览器,输入你的应用的地址,如http://rails:8080/demo,应该就会出现

Congratulations, you've put Ruby on Rails!。

以后每新建一个rails应用时,只要记得修改public/.htaccess文件就可以了,不用重启Apache服务器了。

星期一, 十月 09, 2006

国庆

国庆节过去了,些许兴奋,些许累,些许哀愁...

国庆节我还多休了8号一天。

兴奋:
见到了相隔一个月没有见的老婆。也因此令我会有些觉得可惜,也许这只有我才会这样觉得,也许是我自己有问题。

累:
国庆做了好多事,家具,家电,婚纱照。还去了苏州给老婆买了婚纱和礼服,那晚的大床,很舒服,一直都很期待以后我们的床也能像那样,因为个人很懒,可一直又都很忙,所以很想能好好懒一下。
婚纱照昨天去牛首山拍的,这就不得不提一下我们选择的这家摄影工作室-阶梯摄影,以及我们的摄影师君·痕和化妆师文文(不知道写的对不对),非常感谢这2位的帮助和工作,他们一直陪我们从上午弄到晚上8:30,心里很是感激,谢谢二位。
PS:对于阶梯工作室的业务工作,不作评价。

哀愁:
也许是出于对婚姻的恐惧,之前听说过这种恐惧,从来不以为然,觉得这有什么好怕,如果怕,干嘛要结呢?
我现在知道了,也许其他人和我不同,我怕的是不能开心的生活,怕负担不起婚姻的责任。

不安ing...