在Ubuntu 16/Apache 2.4上安装Phusion Passenger (Setting up Phusion Passenger with Apache 2.4 on Ubuntu)
安装Apache 2 (Install Apache 2)
sudo apt-get install apache2
sudo a2enmod headers
sudo a2enmod expires
配置Apache SSL (Configure Apache SSL)
sudo a2enmod ssl
sudo a2ensite default-ssl.conf
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
安装Phusion Passenger (Install Phusion Passenger)
gem install passenger
passenger-install-apache2-module
按照屏幕提示进行安装, 安装完毕后的apache2.conf文件内容如下 (Follow on screen instructions, so the apache configuration file /etc/apache2/apache2.conf looks like:)
LoadModule passenger_module /home/yuxi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/passenger-5.1.5/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/yuxi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/passenger-5.1.5
PassengerDefaultRuby /home/yuxi/.rbenv/versions/2.3.1/bin/ruby
</IfModule>
在Apache中配置Rails应用 (Configure Rails application in Apache 2.x)
Edit /etc/apache2/sites-enabled/default-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin [email protected]
ServerName localhost
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
RailsEnv production
RailsBaseURI /
Alias / /home/yuxi/rails_app/public
<Location />
PassengerBaseURI /
PassengerAppRoot /home/yuxi/rails_app
</Location>
<Directory /home/yuxi/rails_app/public>
Require all granted
AllowOverride None
Options -MultiViews +FollowSymLinks
Require all granted
</Directory>
<Location /assets/>
Require all granted
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 1 year"
</Location>
</VirtualHost>
</IfModule>
Rails应用程序的配置 (Configurations within Rails application)
为producion模式生成静态资源 (Generate assets for production):
rake assets:precompile RAILS_ENV=production
编辑文件并确保以下内容。(Edit config/environments/production.rb, make sure):
config.public_file_server.enabled = true
你写的代理服务器篇已收藏
哈哈,深感荣幸。。。
This look incredible,thank you for posting this, it’s realy awesome,thank’s for sharing and I hope that you will continue with posting,thank you.
I will do. Thx