오랜만에 글을 올리게 되는군요. 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
'Language > Ruby' 카테고리의 다른 글
Ruby : 파일(디렉토리)이름에 특정 문자열이 포함된 목록 출력하기 (0) | 2011.10.27 |
---|---|
Ruby : 10MB 이상의 파일중에서 중복된 파일 찾기 (0) | 2011.05.17 |
CentOS 5.6 에서 Ruby 설치 (0) | 2011.04.22 |
Debian Linux 6.0(squeeze)에서 Ruby 설치 (0) | 2011.02.10 |
Rails 템플릿 파일 확장명 (0) | 2010.03.18 |