Rails on me :)
2010년 3월 31일 수요일
  Ruby on Rails : Phusion Passenger 설치하기
Phusion Passenger 설치과정을 간단하게 기록하려한다. 본 예제는 Ubuntu 환경이며, Apache2 가 깔려있다는 전제에서 시작된다.

os : Ubuntu 9.10 Karmic Koala
ruby : 1.8 version

> sudo gem install passenger

만약,
Error installing passenger
Failed to build gem native extension

위 메세지가 보인다면,

> sudo apt-get install ruby1.8-dev

를 설치해주면 된다.

이제 다시 passenger 를 설치해보자.

> sudo gem install passenger

Apache2 관련 passenger 모듈 설치하기

> sudo passenger-install-apache2-module

설치과정은 아래 단계를 거치며 진행된다. enter 를 치며, 다음 단계로 진행하면 된다.

step 1.
Welcome to the Phusion Passenger Apache 2 module installer, v2.2.11.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

step2.
Checking for required software...

* GNU C++ compiler... not found

* Ruby development headers... found

* OpenSSL support for Ruby... found

* RubyGems... found

* Rake... found at /usr/bin/rake

* rack... found

* Apache 2... found at /usr/sbin/apache2

* Apache 2 development headers... not found

* Apache Portable Runtime (APR) development headers... not found

* Apache Portable Runtime Utility (APU) development headers... not found

Some required software is not installed.

But don't worry, this installer will tell you how to install them.

Press Enter to continue, or Ctrl-C to abort.

자기 환경에 설치되어 있지 않은 프로그램에 대한 정보를 친절하게 보여준다.  Enter 를 치면 다음단계에서 설치방법에 대해 친절하게 설명해준다.

step 3.
Installation instructions for required software

* To install GNU C++ compiler:

Please run apt-get install build-essential as root.

* To install Apache 2 development headers:

Please run apt-get install apache2-prefork-dev as root.

* To install Apache Portable Runtime (APR) development headers:

Please run apt-get install libapr1-dev as root.

* To install Apache Portable Runtime Utility (APU) development headers:

Please run apt-get install libaprutil1-dev as root.


If the aforementioned instructions didn't solve your problem, then please take

a look at the Users Guide:
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/doc/Users guide Apache.html

위의 메세지대로 하나씩 설치를 한후, 다시 sudo passenger-install-apache2-module 명령을 실행하자.

step 4.
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific

configuration!

Press ENTER to continue.

성공이다. 바탕색이 칠해진 부분은 나중에 apache 설정에 넣어야할 부분임으로 복사해두자.

step 5.
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your Apache configuration file and set its DocumentRoot to /somewhere/public:

<virtualhost *:80="">

  ServerName www.yourhost.com

  DocumentRoot /somewhere/public # <-- be sure to point to 'public'!

  <directory public="" somewhere="">

    AllowOverride all # <-- relax Apache security settings

    Options -MultiViews # <-- MultiViews must be turned off

  </directory>

</virtualhost>

And that's it! You may also want to check the Users Guide for security and

optimization tips, troubleshooting and other useful information:

/usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/doc/Users guide Apache.html

마지막 단계에서는 apache 의 virtual host 설정에 관한 예제도 보여준다.


자기 환경에서 Apache Configure 파일을 찾는 방법은 다음과 같다.
> apache2ctl -V | grep SERVER_CONFIG_FILE
 output> -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"



표시된 경로에 있는 파일을 열고(이때, 반드시 sudo 를 입력하여 root 계정으로 편집해야한다),

Phusion Passenger 설치과정에서 복사한 문구를 파일 끝에 넣는다.

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby1.8

이제 virtualhost 설정을 해주자.
> sudo vim /etc/apache2/sites-available/default


파일에 virtualhost 설정해준다

<virtualhost *:80="">

  ServerName www.yourhost.com

  DocumentRoot /somewhere/public  # <-- be sure to point to 'public'!

  <directory /somewhere/public >

    AllowOverride all   # <-- relax Apache security settings

    Options -MultiViews # <-- MultiViews must be turned off

  </directory>

</virtualhost>

DocumentRoot 선언에 rails 어플리케이션의 public 폴더를 명시하는 점에 주목하자.
참고로, # 주석은 실제 입력시 빼야 문법오류가 안뜬다

설정이 완료되었으면,  apache 를 재시작하자.
> sudo /etc/init.d/apache2 restart

이제 http://localhost/ 로 접속했을 때, rails 어플리케이션이 생성된 폴더가 root 로 잡히는걸 확인할 수 있다.

라벨: ,

 
댓글:
좋은정보 감사합니다~
 
네~ :)
 
댓글 쓰기

에 가입 댓글 [Atom]





<< 홈
with ruby core and CGIs

내 사진
이름:
위치: Seoul, South Korea

모니터 앞에서 싸구려 커피를 마시며

아카이브
3월 2010 / 4월 2010 / 5월 2010 / 6월 2010 / 7월 2010 / 11월 2010 / 12월 2011 /


Powered by Blogger

에 가입
글 [Atom]