Showing posts with label Redmine. Show all posts
Showing posts with label Redmine. Show all posts

2009/10/26

Redmine 한글 PDF 출력 문제

얼마전 부터 Redmine 을 활용하여 프로젝트 관리를 해오고 있는데 Redmine 에서 지원하는 Gantt Chart 와 업무리스트를 PDF 로 출력을 시도해 보았는데 한글이 모두 이상한 문자로 출력이 되었다. 수정할 수 있는지 해서 인터넷에 검색을 해 보았는데 해당 문건이 많지 않았다.

검색된 자료 중 "Redmine pdf export 시 한글 깨지는 문제" 문서를 참조하여 해결을 하였다.

해결 방법은 PDF 출력 루틴과 한국어 출력 부분인데 "Redmine pdf export 시 한글 깨지는 문제" 문서에서 제시한 해결책이 그대로 적용되었다. 단, 버전의 차이에서 인지 수정해야할 파일들의 위치가 달랐다. 검색된 문서에서 제시된 redmine 버전은 0.8이고 현재 설치된 버전은 그 보다 상위 버전인 0.8.5 이다.

우선 PDF 출력 파일을 수정하였다.
파일의 위치는 lib\redmine\export\pdf.rb 이다. 이 파일의 내용중 "zh-tw" 의 내용을 복사하여 한글에 맞도록 수정한다.

  when 'zh-tw'
extend(PDF_Chinese)
AddBig5Font()
@font_for_content = 'Big5'
@font_for_footer = 'Big5'
# 한글 출력을 위해 추가된 부분
when 'ko'
extend(PDF_Korean)
AddUHCFont()
@font_for_content = 'UHC'
@font_for_footer = 'UHC'



다음 수정 사항은 폰트에 대한 것인데, 기본 적으로 명조체 출력을 지원하고 있는데 이 부분을 고딕체로 수정하는 내용이다. 명조체로 출력을 원하면 수정하지 않으면 된다.
수정해야할 파일은 vendor\plugins\rfpdf\lib\rfpdf\korean.rb

# HYSMyeongJoStd-Medium-Acro 를 HYGoThic-Medium로 바꾼다.
def AddUHCFont(family='UHC',name='HYGoThic-Medium')
#Add UHC font with proportional Latin
cw=UHC_widths
cMap='KSCms-UHC-H'
registry={'ordering'=>'Korea1','supplement'=>1}
AddCIDFonts(family,name,cw,cMap,registry)
end

def AddUHChwFont(family='UHC-hw',name='HYGoThic-Medium')
#Add UHC font with half-witdh Latin
32.upto(126) do |i|
cw[i.chr]=500
end
cMap='KSCms-UHC-HW-H'
registry={'ordering'=>'Korea1','supplement'=>1}
AddCIDFonts(family,name,cw,cMap,registry)
end



그리고 MultiCell 함수와 MBMultiCell 함수를 chinese.rb에서 복사해 온다.
아래 내용을 복사해 온 내용이다.

  def MultiCell(w,h,txt,border=0,align='L',fill=0)
if(@CurrentFont['type']=='Type0')
MBMultiCell(w,h,txt,border,align,fill)
else
super(w,h,txt,border,align,fill)
end
end

def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
#Multi-byte version of MultiCell()
cw=@CurrentFont['cw']
if(w==0)
w=@w-@rMargin-@x
end
wmax=(w-2*@cMargin)*1000/@FontSize
s=txt.gsub("\r",'')
nb=s.length
if(nb>0 and s[nb-1]=="\n")
nb-=1
end
b=0
if(border)
if(border==1)
border='LTRB'
b='LRT'
b2='LR'
else
b2=''
if(border.to_s.index('L'))
b2+='L'
end
if(border.to_s.index('R'))
b2+='R'
end
b=border.to_s.index('T') ? b2+'T' : b2
end
end
sep=-1
i=0
j=0
l=0
nl=1
while(i<nb)
#Get next character
c=s[i]
#Check if ASCII or MB
ascii=(c<128)
if(c.chr=="\n")
#Explicit line break
Cell(w,h,s[j,i-j],b,2,align,fill)
i+=1
sep=-1
j=i
l=0
nl+=1
if(border and nl==2)
b=b2
end
next
end
if(!ascii)
sep=i
ls=l
elsif(c==' ')
sep=i
ls=l
end
l+=ascii ? (cw[c.chr] || 0) : 1100
if(l>wmax)
#Automatic line break
if(sep==-1 or i==j)
if(i==j)
i+=ascii ? 1 : 3
end
Cell(w,h,s[j,i-j],b,2,align,fill)
else
Cell(w,h,s[j,sep-j],b,2,align,fill)
i=(s[sep]==' ') ? sep+1 : sep
end
sep=-1
j=i
l=0
# nl+=1
if(border and nl==2)
b=b2
end
else
i+=ascii ? 1 : 3
end
end
#Last chunk
if(border and not border.to_s.index('B').nil?)
b+='B'
end
Cell(w,h,s[j,i-j],b,2,align,fill)
@x=@lMargin
end



이제 redmine 을 재시작하고 Gantt Chart 나 작업 목록에서 PDF로 출력을 해보면 한글이 깨끗하게 나오는 걸 확인할 수 있다

Original Post : http://neodreamer-dev.tistory.com/337

2009/09/21

윈도우에서 redmine + mongrel + apache (Load Balance) 설정하기

프로젝트 관리 프로그램인 redmine 에 대해서 이것 저것 테스트 해 보다가 실제 적용을 하기 위해 마지막 테스트를 하였다. 기존 XAMPP 기반에서 redmine 을 함께 서비스 하기로 하였고 그에 따른 방법을 찾아 보았다.

우선 redmine 을 서브 폴더(http://localhost:3000/redmine )로 접근 하도록 설치를 하려면 config/environment.rb 파일 맨 마지막에 아래의 코드를 추가 해 주어야 한다.
ActionController::AbstractRequest.relative_url_root = "/redmine" 


하지만 rails 2.3.x 에서 서브 폴더로 설치하면 접근을 할 수 없는 버그가 있다고 한다. 그러한 내용을 모르고서 작업을 하며 엄청난 삽질을 하다가 결국엔 다른 방법을 찾았다.

rails를 설치할 때 아래와 같은 명령으로  2.2.2 버전을 설치하였다.
gem install rails -v 2.2.2 --inlucde-dependencies -y



redmine을 최근 소스를 받을 경우 rails 를 2.3.4 버전을 사용해야 하기 때문에 0.8.5 버전으로 설치 한다.
Redmine - Windows XP 에서 수동 설치하기

그리고 redmine 의 config/environment.rb 파일에 아래의 코드를 추가 하였다.
ActionController::AbstractRequest.relative_url_root = "/redmine" 



Load Balancing 을 하기 위해 mongrel 을 이용하여 두 개의 서버스를 등록하였다.
mongrel_rails service::install -N redmine1 -D redmine1 -p 3001 -n 1024 -c C:\Dev
edmine -e production --prefix=/redmine

mongrel_rails service::install -N redmine2 -D redmine2 -p 3002 -n 1024 -c C:\Dev
edmine -e production --prefix=/redmine



net start redmine1

net start redmine2



서비스가 정상적으로 실행 되었는지 확인하기 위해서는 http://localhost:3001/redmine 과 http://localhost:3002/redmine 으로 접속하여 redmine 의 초기 화면이 출력되는지 확인 하면 된다.

이제 Apache와의 연결만이 남아 있다. 연결을 위한 코드는 매우 간단하다.
ProxyPass /redmine balancer://redminecluster

ProxyPassReverse /redmine balancer://redminecluster



<Proxy balancer://redminecluster>

BalancerMember http://127.0.0.1:3001/redmine

BalancerMember http://127.0.0.1:3002/redmine

</Proxy>



위의 코드를 Apache의 httpd.conf 파일의 마지막에 첨부 하던지 새 파일을 만들어서 Include 를 시켜주고 Apache 를 재 시작 해주면 된다.
브라우저로 http://localhost/redmine 로 접속을 하여 redmine 화면이 나오면 성공한 것이다.

마지막으로 시스템이 재 부팅 되었을 경우 redmine1 과 redmine2 가 자동으로 실행되게 하기 위해서 아래의 명령을 도스 창에서 수행한다.
sc config redmine1 start= auto depend= MySQL

sc config redmine2 start= auto depend= MySQL


위의 코드는 redmine1 과 redmine2 가 MySQL 서비스가 시작 된 후 자동으로 시작되도록 하는 명령이다.<

Original Post : http://neodreamer-dev.tistory.com/327

2009/09/16

Redmine 서비스로 등록하기

지난 포스팅에서 Redmine 을 XP 설치하는 글을 올렸었다.

2009/09/16 - [Dev Story] - Redmine - Windows XP 에서 수동 설치하기



지난 글에 이어 설치 된 Redmine 을 Windows의 서버스로 등록을 하여 실행을 시켜 보았다.



우선 서버스로 등록을 하기 위해서는 mongrel 가 필요하다. 설치 방법은 아래와 같다.



C:\Dev
uby>gem install mongrel mongrel_service --include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Successfully installed gem_plugin-0.2.3
Successfully installed cgi_multipart_eof_fix-2.5.0
Successfully installed mongrel-1.1.5-x86-mswin32-60
Successfully installed win32-service-0.5.2-x86-mswin32
Successfully installed mongrel_service-0.3.4-x86-mswin32
5 gems installed
Installing ri documentation for gem_plugin-0.2.3...
Installing ri documentation for cgi_multipart_eof_fix-2.5.0...
Installing ri documentation for mongrel-1.1.5-x86-mswin32-60...
Installing ri documentation for win32-service-0.5.2-x86-mswin32...
Installing ri documentation for mongrel_service-0.3.4-x86-mswin32...
Installing RDoc documentation for gem_plugin-0.2.3...
Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0...
Installing RDoc documentation for mongrel-1.1.5-x86-mswin32-60...
Installing RDoc documentation for win32-service-0.5.2-x86-mswin32...
Installing RDoc documentation for mongrel_service-0.3.4-x86-mswin32...




아래는 Redmine 을 서비스로 등록하는 명령이다.



C:\Dev
uby>mongrel_rails service::install -N RedmineSvr -p 3001 -e production -c C:\Dev\Rails\Redmine
** Copying native mongrel_service executable...
Mongrel service 'RedmineSvr1' installed as 'RedmineSvr1'.




등록을 마쳤으면 서비스를 실행 시킨다.



C:\Dev
uby>net start RedmineSvr




이제 브라우저에서 http://localhost:3001/ 로 접속을 하면 Redmine 을 볼 수 있다. PC가 부팅될 때 마다 자동으로 실행 시키고자 할 경우 "내 컴퓨터" 에서 오른쪽 버튼 클릭시 나오는 메뉴 중 "관리" 메뉴에서 서비스 항목 중 RedmineSvr 를 찾아 자동실행으로 설정 해 놓으면 된다.<

Original Post : http://neodreamer-dev.tistory.com/325

Redmine - Windows XP 에서 수동 설치하기

버그및 프로젝트 관리 프로그램으로 Redmine 을 선택하려고 가상PC에 설치를 해 보았다.
쉽게 설치하려면 Bitnami Redmine Stack 을 이용하면 되지만 기존 운영중인 DB나 웹서버가 있을 경우 수동으로 설치하는 것이 나을 것 같아 설치를 해 보았다.

기본적인 설치 순서는 Redmine 사이트에 있는 Install 문서를 바탕으로 진행 했다. 하지만 추가적으로 진행 해야 할 사항도 있었다.

현재 시스템은 XAMPP 1.7.2 으로 되어 있고, Ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] 버전과 Rails 2.3.4 버전이 설치 되어 있는 상태이다.
Ruby 와 Rails 설치는 2009/09/12 - [Dev Story] - XP에 Ruby on Rails 설치하기 를 참고하면 된다.

Redmine 을 수동 설치할 때는 Rails 의 버전을 고려해야 한다고 한다.  아래 테이블은 Redmine 사이트에서 발췌한 것으로 Redmine 구동에 필요한 Ruby 및 Rails 버전 테이블 이다.




















































Redmine versionSupported Ruby versionsRequired Rails version
current trunkruby 1.8.6, 1.8.7Rails 2.3.4
trunk from r2493 to r2886ruby 1.8.6, 1.8.7Rails 2.2.2
trunk before r2493ruby 1.8.6, 1.8.7Rails 2.1.2
0.8.xruby 1.8.6, 1.8.7Rails 2.1.2
0.7.xruby 1.8.6Rails 2.0.2

Rails 를 2.3.4 버전을 설치해 놓은 상태라서 현재 개발 중인 redmine 을 SVN (TortoiseSVN) 을 받았다. (r2888) (설치 경로는 C:\Dev\Rails\Redmine 으로 하였음.)

MySQL 서버 설정
먼저 데이터베이스를 준비한다. XAMPP 를 설치하면 MySQL이 설치되는데 redmine 에서 사용하기 위해서 유니코드를 지원토록 my.ini 에 아래와 같은 내용을 추가한다.
[mysqld]

default-character-set=utf8

character-set-server=utf8

collation-server=utf8_general_ci



[mysql]

default-character-set=utf8



MySQL을 재시작 한 후 mysql에 접속하여 redmine 을 위한 데이터베이스를 생성위해 아래 Query 문을 실행한다.
create database redmine character set utf8;

create user 'redmine'@'localhost' identified by 'redadmin';

grant all privileges on redmine.* to 'redmine'@'localhost';



MySQL 접속 환경 설정
Redmine 프로젝트 폴더(C:\Dev\Rails\Redmine) 안에 config 폴더의 database.yml.example 파일을 database.yml 으로 바꾸고 아래와 같은 내용으로 작성을 한다.
production:

adapter: mysql

database: redmine

host: localhost

username: redmine

password: redadmin

port: 3306

encoding: utf8



Session store secret 생성하기
secret 을 Redmine Trunk r2493 이상 설치시 필요하며 아래와 같은 명령을 수행하여 생성한다.
C:\Dev
ails
edmine>rake config/initializers/session_store.rb

(in C:/Dev/rails/redmine)



데이터베이스 생성하기
Redmine 운영시 사용될 데이터베이스로 아래 명령을 수행하여 생성한다.
C:\Dev
ails
edmine>rake db:migrate RAILS_ENV="production"


위 명령을 수행할 때 루비가 설치된 경로(C:\Dev\Ruby)에 bin 폴더 안에 libmysql.dll 이 없을 경우 아래와 같은 에러 메세지를 만나게 된다.
C:\Dev
ails
edmine>rake db:migrate RAILS_ENV="production"

(in C:/Dev/rails/redmine)

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install

the mysql gem and try again: gem install mysql.

rake aborted!

126: 지정된 모듈을 찾을 수 없습니다. - c:/Dev/ruby/lib/ruby/gems/1.8/gems/mys

l-2.8.1-x86-mswin32/lib/1.8/mysql_api.so



(See full trace by running task with --trace)


MySQL 이 설치된 경로(C:\XAMPP\MySQL) 폴더의 bin 폴더 안에 있는 libmysql.dll 을 Ruby 의 Bin 폴더(C:\Dev\Ruby\Bin)에 복사해 준다.

그리고 아래와 같은 에러가 발생할 경우에는 Redmine 의 database.yml 파일의 설정을 확인하여야 한다.
C:\Dev
ails
edmine>rake db:migrate RAILS_ENV="production"

(in C:/Dev/rails/redmine)

rake aborted!

Access denied for user 'root'@'localhost' (using password: YES)



(See full trace by running task with --trace)


모든 설정을 확인하였는데 아래와 같은 에러가 나타날 때가 있다.
C:\Dev
ails
edmine>rake db:migrate RAILS_ENV="production" --trace

(in C:/Dev/rails/redmine)

** Invoke db:migrate (first_time)

** Invoke environment (first_time)

** Execute environment

** Execute db:migrate

rake aborted!

Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version`

varchar(255) NOT NULL) ENGINE=InnoDB

:

:


위 에러는 Redmine 의 설치 메뉴얼에 설명이 나와 있지 않아 구글 검색을 통해 찾았는데 libmysql.dll 버전 문제라고 한다. 최신 버전의 libmysql.dll 을 사용할 경우 발생한다고 한다. XAMPP 1.7.2 버전에는 MySQL 5.1.37 버전에 설치되어 있는데 이 버전도 문제가 되었다. 문제가 없는 libmysql.dll 파일을 다운받아 Ruby 의 bin 폴더에 복사하고 MySQL 을 재가동 시킨 후 데이터베이스 생성 명령을 수행한다.

C:\Dev
ails
edmine>rake db:migrate RAILS_ENV="production" --trace

(in C:/Dev/rails/redmine)

** Invoke db:migrate (first_time)

** Invoke environment (first_time)

** Execute environment

** Execute db:migrate

:

:

:

** Invoke db:schema:dump (first_time)

** Invoke environment

** Execute db:schema:dump


기본 설정 데이터 추기하기
이 과정은 옵션이지만 Redmine 의 설치 문서에는 강력하게 추천을 하고 있다. 아래 명령을 통해 기본 설정 데이터를 추가한다. 추가할때 언어를 물어 볼 때 ko 를 입력한다.

C:\Dev
ails
edmine>rake redmine:load_default_data RAILS_ENV="production"

(in C:/Dev/rails/redmine)



Select language: bg, bs, ca, cs, da, de, el, en, es, fi, fr, gl, he, hu, it, ja,

ko, lt, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sr, sv, th, tr, uk, vi, zh, zh-T

W [en] ko

====================================

Default configuration data loaded.


이것으로 Redmine 설치가 끝이 났다. 이제 테스트를 위해 Redmine 을 실행 시킨다.

C:\Dev
ails
edmine>ruby script/server webrick -e production

=> Booting WEBrick

=> Rails 2.3.4 application starting on http://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

[2009-09-16 12:46:21] INFO WEBrick 1.3.1

[2009-09-16 12:46:21] INFO ruby 1.8.6 (2007-09-24) [i386-mswin32]

[2009-09-16 12:46:21] INFO WEBrick::HTTPServer#start: pid=2756 port=3000


브라우저를 실행하고 http://localhost:3000 로 접속을 해 보면 Redmine 을 만날 수 있다.

우상단의 로그인메뉴를 통해 접속하여 관리할 수 있다.


관리자 계정 : admin


관리자 암호 : admin

이대로 사용을 해도 되지만 XAMPP 와 연동을 하여 사용하면 더 좋을 것 같다. <

Original Post : http://neodreamer-dev.tistory.com/324