Could not reliably determine the server's fully qualified domain name, using 123.456.789.123 for ServerName
윈도우상에서 한동안 이런 아파치2.2의 에러와 함께 레일스 도메인이 애플리케이션과 맵핑되지 않는 문제가 있었는데, 어느새 풀렸다. 솔직히 왜 이러는건지는 잘 모르겠다;

차후 문제를 위해 기록해둔다

httpd.conf 파일에

기본 포트를 설정하고
Listen 80

module을 로드한다

LoadModule deflate_module modules/mod_deflate.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule rewrite_module modules/mod_rewrite.so

가상호스트 설정은

<VirtualHost *:80>
    ServerAdmin sirius@abc.com
    DocumentRoot "C:/web_apps/myapp/public"
    #ServerName www.mydomain.net
    ServerAlias mydomain.net

    <Directory "C:/web_apps/myapp/public">
      options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
     
    <Proxy balancer://mongrel_cluster>
     BalancerMember http://127.0.0.1:4001
     BalancerMember http://127.0.0.1:4002
    </Proxy>
   
    RewriteEngine On

    # Uncomment for rewrite debugging
    #RewriteLog logs/your_app_deflate_log deflate
    #RewriteLogLevel 9
    # Check for maintenance file and redirect all requests
    RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
    RewriteCond %{SCRIPT_FILENAME} !maintenance.html
    RewriteRule ^.*$ /system/maintenance.html [L]
    RewriteRule ^/$ /index.html [QSA]

   # Rewrite to check for Rails cached page
   RewriteRule ^([^.]+)$ $1.html [QSA]
  
   # Redirect all non-static requests to cluster
   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
   RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
  
   # Deflate
   AddOutputFilterByType DEFLATE text/html text/plain text/xml
   BrowserMatch ^Mozilla/4 gzip-only-text/html
   BrowserMatch ^Mozilla/4\.0[678] no-gzip
   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  
   # Uncomment for deflate debugging
   #DeflateFilterNote Input input_info
   #DeflateFilterNote Output output_info
   #DeflateFilterNote Ratio ratio_info
   #LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
   #CustomLog logs/your_app_deflate_log deflate

    ErrorLog "C:/apache/logs/error.log"
</VirtualHost>

[Deploying Rails Applications 참고]

mongrel_rails로 서비스를 등록하여 관리한다

mongrel_rails service::install -N MyApp_4001 -p 4001 -e production
mongrel_rails service::install -N MyApp_4002 -p 4002 -e production

p.s
간혹, 예전 apache 버전이 완전히 지워지지 않아 문제 생기는 것도 있다.
방화벽도 확인 바람!

위 책에 나온걸 보면 윈도우는 리눅스에 비해 성능은 대략 반정도 된다고 하더라

• Change how you use sessions. How are sessions managed in your
application? The P-Store, or file-based store, can often be slow.
Consider moving your session store into your database, or investigate
other session-storing mechanisms.
• Go through your development logs, and make sure you’re not
making unnecessary calls to your database. Simply adding an
:include to a finder can really help an application’s performance,
and it is often missed.
• Use fragment, action, and page caching as much as you can. Since
Ruby is slow on Windows, you want to make as much use of page
caching as you possibly can so that Rails is never invoked.
• Ensure that nothing is interfering with the process. Certain security
auditing software, quota managers, and virus scanners can
drastically reduce the amount of requests you can handle. Watch
your performance monitor for any spikes when testing your
application.

윈도우 레일즈 성능 최적화 부분만 따왔다.

Posted by Elegant Universe
acts_as_taggable_on_steroids 플러그인과 will_paginate 플러그인을 둘다 사용할 경우에 막히네...

여러 코드 찾아 돌아당겨보며 적용해도
(http://www.mckinneystation.com/2007/08/20/pagination-with-acts_as_taggable_on_steroids-acts_as_ferret-and-will_paginate/)
이런 방안이 있는데, 현재 will_paginate 버전에서 계속 적용이 안되서,

http://github.com/mislav/will_paginate/tree/master
에서 예전버전을 찾아 적용했는데도 find_all_by_tag 메서드를 못찾겠다는 소리가 나온다.

acts_as_taggable_on_steroids 플러그인은, 쉽게 태그를 생성, 찾을 수 있고, 태그클라우드 까지 가능한 플러그인.
will_paginate는 페이지 번호를 적용할 때, 기존의 sql문을 통해 접근할 필요 없이,

-view
<%= will_paginate @articles %>

-controller
// 기본 페이지 번호
@articles = Article.paginate   :page => params[:page], :order => 'created_at DESC', :per_page => 10
// 분류별 페이지 번호
@articles = Article.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
// 태그별 페이지 번호
 ---안됨--

이렇게 손쉽게 페이저번호 붙일 수 있는 플러그인.

사실, 이 페이지번호 쪽이 제일 성가시고 까다로운 부분이라, 아무래도 will_paginate 속살을 살살 벗겨봐야 겠다.
Posted by Elegant Universe

플렉스에선, 다른 서버의 업로드와 똑같이, 파일업로드기능 구현후 UrlRequest를 통해, url을 레일스의 컨트롤러 경로에 보낸다.

그리고, 레일스에는

Class UploadController < ApplicationController
 def load
   if saveloadFile(params[:Filedata],params[:Filename].to_s)
      render(:xml => "")
   end
 end

여기서 saveloadFile은 곧 만들게 될 정의함수이고, :Filedata, :Filename 해시를 통해 파일의 정보를 받아오게 된다. 그걸 saveloadFile 함수에 넘겨줘서 true를 호출한다면, 렌더링 된다.

  def saveloadFile(fdata, fname)
    filePath = "저장할 경로/+fname"
    if File.open(filePath, "wb") { |b| b.write(fdata.read) }
      return true
    else
      return false
    end
  end

 경로를 지정하여, 파일이름 복수문제가 있을 경우엔 Time.now() 함수 같은걸로 해당시간을 고유키로 만들어 붙이는 방식으로 해결할 수 있다.

//참고
http://mindrulers.blogspot.com/2007/04/file-upload-in-flex-rubu-on-rails_3231.html

Posted by Elegant Universe
황대산 님의 책을 보고 구현하다가, scaffold 부분에서 계속 막혔다.
특히 2.0 버전으로 업뎃되면서, scaffold 기능도 없어지고, sqlite로 db가 기본설정되니, 막히는 부분이 많았다.
이것 저것 찾아보면서, 드디어 해결책을 본바...

2.0버전에서 scaffold 기능 추가하는 방법은 다른데 찾아보면 자세히 설명되어 있고, 나는 귀찮아서, 최소한의 변경만 고려했다.

책의 예제들을 실행하기 위해, 필요한 부분을 나열한다.

1.  최신버전일 경우 1.2.3 버전으로 회귀한다
c:\> gem uninstall rails
c:\> gem install rails --version '= 1.2.3' --include-dependencies

2. mysql을 실행하기 위해
바로 rails phonebook이라고 해버리면,
database.yml 에 sqllite로 설정이 되버린다.

그러므로, mysql을 사용하려면

rails -d mysql phonebook

식으로 명시적으로 사용, 생성한다.
또한, database.yml 파일도 그에 맞게 수정한다.

3. mysql은 4.1이나 5.0 버전을 이용한다.
database.yml 파일 안에도 그렇게 쓰여져있고, 본인은 최신 버전인 mysql6.0을 사용하다가 피봤다. 그러므로 5.0버전 중 최신버전을 이용한다.

이렇게 하면, 아직까지는 큰 탈 없이 잘 된다.

4. rake 기능이 안먹히는 경우가 있다.
가령, rake db:migrate를 실행했을때,
c:/ruby/bin/rake.bat:24: undefined method `require_gem' for main:Object (NoMethodError)
라는 메시지를 보게 되는 경우, 해결방법은
위의 rake.bat 파일을 열어, 밑의
require_gem 'rake'version
 gem 'rake',version
로 바꾸어 준다.
아, 버전에 따라 막히는 부분들이, 슬슬 짱나...ㅜ

5. BlueCloth 라이브러리를 사용하기 위해, 설치하려고 책에 나와있는대로 실행하면,
c:/web_apps/blog_app>gem install bluecloth
Error:  could not find bluecloth locally or in a repository
라고 뜬다.
해결방안은, 명시적으로 찾아 설치하게끔 만든다.
gem query -rn Blue 라고 치면,
*** REMOTE GEMS ***
BlueCloth (1.0.0)
bluepay (1.0.1)
로 찾고
gem install -r BlueCloth 라고 치므로써
Successfully installed BlueCloth-1.0.0
설치가 된다.
Posted by Elegant Universe

카테고리

전체 (118)
Programming (15)
Digital Nomad (2)
Projects (7)
Sound (14)
Travel (69)
Think (9)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

글 보관함