6、生成会话密钥
cd /usr/local/redmine
rake generate_secret_token
若出现以下错误提示:
-------------------------------------------------------------------------------------------------------------
[root@test config]# rake generate_secret_token
(in /usr/local/redmine)
Could not find gem 'rails (= 3.2.16) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
如果报passenger-install-apache2-module这条命令找不到的话,那么通过下面的命令查看执行路径:
gem environment
RubyGems Environment:
– RUBYGEMS VERSION: 1.3.7
– RUBY VERSION: 1.8.7 (2009-04-08 patchlevel 160) [i686-linux]
– INSTALLATION DIRECTORY: /usr/local/ruby/lib/ruby/gems/1.8
– RUBY EXECUTABLE: /usr/local/ruby/bin/ruby
– EXECUTABLE DIRECTORY: /usr/local/ruby/bin
– RUBYGEMS PLATFORMS:
– ruby
– x86-linux
– GEM PATHS:
– /usr/local/ruby/lib/ruby/gems/1.8
– /root/.gem/ruby/1.8
– GEM CONFIGURATION:
– :update_sources => true
– :verbose => true
– :benchmark => false
– :backtrace => false
– :bulk_threshold => 1000
– REMOTE SOURCES:
– http://rubygems.org/
其中,EXECUTABLE DIRECTORY就是命令的全路径,所以对于我例子里的情况执行/usr/local/ruby/bin/passenger-install-apache2-module
根据提示安装和部署。passenger会在本机编译并成为apache的一个模块。安装过程中会遇到下面的提示信息(根据版本的不同,信息也会稍有变化):
Welcome to the Phusion Passenger Apache 2 module installer, v2.2.15.
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.
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/local/ruby/bin/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!
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:
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <– be sure to point to ‘public’!
AllowOverride all # <– relax Apache security settings
Options -MultiViews # <– MultiViews must be turned off
And that’s it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:
/usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/doc/Users guide Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) http://www.modrails.com/
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
根据提示信息部署:
首先,编辑apache的配置文件(/etc/httpd/conf/httpd.conf)并添加下面的信息:
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/local/ruby/bin/ruby
然后启用Apache的虚拟主机支持:
1、注释掉原有的ServerName,ServerAdmin,DocumentRoot的信息;
2、启用虚拟主机的支持,去掉NameVirtualHost *:80前面的#;
3、在配置文件的末尾加上:
<VirtualHost *:80>
ServerName redmine.loosky.net
ServerAdmin loosky@fjut.edu.cn
DocumentRoot /var/www/redmine/public
ErrorLog logs/redmine_error_log
<Directory “/var/www/redmine/public”>
Allow from all
AllowOverride all
</Directory>
</VirtualHost>
4、重启Apache服务器:service httpd restart