abbuggy@abbuggy-ubuntu:~$ passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.18.
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. 回车确定之后,会进行依赖关系的检查,有部分内容不通过没有关系,回车之后会提示如何解决。
Checking for required software...
* GNU C++ compiler... found at /usr/bin/g++
* Curl development headers with SSL support... found
* OpenSSL development headers... found
* Zlib development headers... found
* Ruby development headers... found
* OpenSSL support for Ruby... found
* RubyGems... found
* Rake... found at /home/abbuggy/.rvm/wrappers/ruby-1.9.2-p320/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. 按照提示将缺少的依赖包,比如我缺少apache2-perfork-dev,libapr1-dev,libaprutil1-dev这三个包。
--------------------------------------------
Installation instructions for required software
* 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.
程序也给出了解决方法。虽然是分别给出的,但我们可以一并执行。你的环境可能和我不一样,按照上面的提示来九成。
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /home/abbuggy/.rvm/gems/ruby-1.9.2-p320/gems/passenger-3.0.18/ext/apache2/mod_passenger.so
PassengerRoot /home/abbuggy/.rvm/gems/ruby-1.9.2-p320/gems/passenger-3.0.18
PassengerRuby /home/abbuggy/.rvm/wrappers/ruby-1.9.2-p320/ruby
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的配置文件位于/etc/apache2/httpd.conf,编辑并添加之。到目前为止,httpd.conf是这样的。
sudo ln -s /home/abbuggy/workspace/simple_cms/public /var/www/simple-cms 不过我自己配置的时候,死活配不对,总是提示"We're sorry,but something went wrong!"临近崩溃边缘时终于找到解决方案。”The defaultRAILS_ENV environment in which deployed Rails applicationsare run, is “production”. You can change this by changing theRailsEnv configuration option.“ --来自于Phusion Passenger users guide
即缺省生效的是production环境,如果在调试时使用development环境的话需要在apache配置文件中增加一行RailsEnv development,所以正确的配置是。
ServerName localhost
DocumentRoot /var/www
Allow from all
RailsBaseURI /simple-cms
RailsEnv development
Options -MultiViews
重启apache,sudo service apache2 restart,访问localhost/simple-cms成功。