"스트럿츠2 프로그래밍" 이라는 책에서 이용되는 struts 버전은 2.0.9 입니다. 해당버전을 다운로드 받아서 압축을 풀어보면 많은 파일들이 있는데, 이 중에서 아래 파일들을 WEB-INF/lib 에 복사하라고 나옵니다.
antlr-2.7.2.jar
commons-beanutils-1.7.0.jar
commons-chain-1.2.jar
commons-logging-1.0.4.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
freemarker-2.3.13.jar
ognl-2.6.11.jar
oro-2.0.8.jar
struts-core-1.3.10.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
2.0.9 에서는 위와 같이 복사를 하면 되지만, 최신 버전인 2.1.6 에서는 톰캣 기동시에 설정을 제대로 적용하지 못하게 됩니다. 이 문제를 해결하려면, 아래 파일 4개를 추가로 복사해주면 됩니다.
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
struts2-dojo-plugin-2.1.6.jar
aopalliance-1.0.jar
해결책은 간단하지만, 문제가 발생하면 원인도 잘 몰라서 골치아프죠. 이 외에도 2.0.x 에서 2.1.x 로 변경되면서 바뀌는 사항에 대해서는 http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html 에서 확인할 수 있습니다. 많은 부분이 변경되서 2.1.x 기반의 책이 나와야 공부하기 편하겠어요. ^^
2009-03-20
2009-03-03
Install Apache 2.2 + Passenger + PostgreSQL
오랜만에 글을 올리게 되는군요. Rails 공부하면서 환경설정하는 부분을 정리해보았습니다. 예전에는 Mongrel 을 이용해서 복작습럽게 설치했었는데, 이제는 mod_rails(passenger)를 이용해서 아주 간단하게 설치/설정을 할 수 있게 되었네요. 본 설치설명서에서는 Debian Linux Squeeze(또는 etch) 에서 설치하는 것을 가정합니다.
[기본 패키지 설치]
# apt-get install ssh ntp htop build-essential vim vim-ruby
[루비 설치]
* 루비 패키지 설치
# apt-get install ruby irb ri rdoc ruby1.8-dev libopenssl-ruby
* /etc/profile 수정
export PATH=/var/lib/gems/1.8/bin:$PATH
* gem 소스 설치 : 2009년 3월 2일 현재 1.3.1 이 최신 버전이다.
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
# tar xvfz rubygems-1.3.1.tgz
# cd rubygems-1.3.1
# ruby setup.rb
위와 같이 설치하면 /usr/bin/gem1.8 으로 gem 실행파일이 생성된다. 그러므로 다음과 같이 심볼릭 링크를 만들어주면 gem 으로 실행할 수 있을 것이다.
# cd /usr/bin
# ln -s gem1.8 gem
* gem 업데이트
# gem update; gem update --system
[Rails 설치]
* Rails 2.2.2 를 설치한다.
# gem install rails -v=2.2.2
[PostgreSQL 설치]
* PostgreSQL 설치
# apt-get install postgresql-8.3 postgresql-server-dev-8.3
* 사용자, DB 생성
# su - postgres
# psql
template1=# CREATE USER 아이디 WITH PASSWORD '비밀번호';
template1=# CREATE DATABASE 디비이름 WITH ENCODING='utf-8' OWNER 아이디;
* 계정으로 로그인할 수 있도록 연결설정
# su -
# cd /etc/postgresql/8.3/main/
# vi pg_hba.conf
모두 주석으로 막고 아래만 남김
host all all 0.0.0.0 0.0.0.0 password
local all postgres trust
local all all password
# /etc/init.d/postgresql restart
# psql -d 디비이름 -U 아이디 -W
[프로젝트 생성]
* postgres 모듈 설치 / 프로젝트 생성
# gem install postgres
# mkdir -p /opt/project
# cd /opt/project/
# rails 프로젝트이름 -d postgresql
* config/database.yml 수정
development:
adapter: postgresql
encoding: unicode
database: 디비이름
pool: 5
username: 아이디
password: 비밀번호
[Apache 2.2 + mod_rails 설치]
* Apache 2.2 설치
# apt-get install apache2 apache2-utils apache2-prefork-dev
* mod_rails(passenger) 설치
# gem install passenger
# passenger-install-apache2-module
* passenger 설정
# vi /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8
# Change this depending on the amount of memory your server has. For a 256MB system, a value of 2 is suggested.
# For a system with 2 GB of memory, a value of 30 is suggested. The default value is 6.
# PassengerMaxPoolSize 2
# a2enmod passenger
* 버추얼 호스트 설정
# vi /etc/apache2/sites-available/프로젝트이름
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 도메인이름
DocumentRoot /opt/project/프로젝트이름/public
</VirtualHost>
# a2ensite 프로젝트이름
# a2dissite 000-default
# /etc/init.d/apache2 restart
[기본 패키지 설치]
# apt-get install ssh ntp htop build-essential vim vim-ruby
[루비 설치]
* 루비 패키지 설치
# apt-get install ruby irb ri rdoc ruby1.8-dev libopenssl-ruby
* /etc/profile 수정
export PATH=/var/lib/gems/1.8/bin:$PATH
* gem 소스 설치 : 2009년 3월 2일 현재 1.3.1 이 최신 버전이다.
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
# tar xvfz rubygems-1.3.1.tgz
# cd rubygems-1.3.1
# ruby setup.rb
위와 같이 설치하면 /usr/bin/gem1.8 으로 gem 실행파일이 생성된다. 그러므로 다음과 같이 심볼릭 링크를 만들어주면 gem 으로 실행할 수 있을 것이다.
# cd /usr/bin
# ln -s gem1.8 gem
* gem 업데이트
# gem update; gem update --system
[Rails 설치]
* Rails 2.2.2 를 설치한다.
# gem install rails -v=2.2.2
[PostgreSQL 설치]
* PostgreSQL 설치
# apt-get install postgresql-8.3 postgresql-server-dev-8.3
* 사용자, DB 생성
# su - postgres
# psql
template1=# CREATE USER 아이디 WITH PASSWORD '비밀번호';
template1=# CREATE DATABASE 디비이름 WITH ENCODING='utf-8' OWNER 아이디;
* 계정으로 로그인할 수 있도록 연결설정
# su -
# cd /etc/postgresql/8.3/main/
# vi pg_hba.conf
모두 주석으로 막고 아래만 남김
host all all 0.0.0.0 0.0.0.0 password
local all postgres trust
local all all password
# /etc/init.d/postgresql restart
# psql -d 디비이름 -U 아이디 -W
[프로젝트 생성]
* postgres 모듈 설치 / 프로젝트 생성
# gem install postgres
# mkdir -p /opt/project
# cd /opt/project/
# rails 프로젝트이름 -d postgresql
* config/database.yml 수정
development:
adapter: postgresql
encoding: unicode
database: 디비이름
pool: 5
username: 아이디
password: 비밀번호
[Apache 2.2 + mod_rails 설치]
* Apache 2.2 설치
# apt-get install apache2 apache2-utils apache2-prefork-dev
* mod_rails(passenger) 설치
# gem install passenger
# passenger-install-apache2-module
* passenger 설정
# vi /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8
# Change this depending on the amount of memory your server has. For a 256MB system, a value of 2 is suggested.
# For a system with 2 GB of memory, a value of 30 is suggested. The default value is 6.
# PassengerMaxPoolSize 2
# a2enmod passenger
* 버추얼 호스트 설정
# vi /etc/apache2/sites-available/프로젝트이름
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 도메인이름
DocumentRoot /opt/project/프로젝트이름/public
</VirtualHost>
# a2ensite 프로젝트이름
# a2dissite 000-default
# /etc/init.d/apache2 restart
피드 구독하기:
글 (Atom)