因为ruby自带的webrick端口用的是3000,而因为一些原因,我的服务器没开3000端口,同时也因为性能问题,那就直接上apache2吧。
gem install passenger passenger-install-apache2-module
如果报passenger-install-apache2-module这条命令找不到的话,那么通过下面的命令查看执行路径:
gem environment
RubyGems Environment: - RUBYGEMS VERSION: 1.3.5 - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] - INSTALLATION DIRECTORY: /var/lib/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin - RUBYGEMS PLATFORMS: - ruby - x86-linux - GEM PATHS: - /var/lib/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://gems.rubyforge.org/ 其中,EXECUTABLE DIRECTORY就是命令的全路径,所以对于我例子里的情况执行 /var/lib/gems/1.8/bin/passenger-install-apache2-module sudo apt-get install libcurl4-openssl-dev libcurl4-gnutls-dev 根据提示安装和部署。passenger会在本机编译并成为apache的一个模块。安装过程中会遇到下面的提示信息(根据版本的不同,信息也会稍有变化): Welcome to the Phusion Passenger Apache 2 module installer, v2.2.13. 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 /var/lib/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.8 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! 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 /somewhere/public> 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:
/var/lib/gems/1.8/gems/passenger-3.0.8/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. 根据提示信息部署。
在/etc/apache2/sites-available添加一个站点: vim redmine 并添加如下内容:
RailsEnv
production
RailsBaseURI /redmine
PassengerDefaultUser www-data
Redmine的Web内容在/usr/share/redmine/public中,在web根目录建立redmine主目录的符号链接,并设置权限:
ln -s /usr/local/redmine/public /var/www/redmine chown -R www-data:www-data /var/www
启用redmine站点: a2ensite redmine
最后重启apache: /etc/init.d/apache2 restart
或,重新加载配置: /etc/init.d/apache2 reload