我有以下配置:
Ubuntu 16.04
Rails 3.2
Ruby 1.9
Passenger 4.0.37
nginx(不确定版本)
应用程序使用rvm
很好地哼唱现在我正在尝试使用不同的ruby和rails版本的sub uri。我正在使用这篇文章作为模板:
我的主应用程序位于www / gi,我的子uri位于www / r5
作为基础测试,我在gi / public和r5 / public都有一个index.html。
我可以http到gi / index.html AND gi / r5 / index.html
然后我使用索引方法在r5中创建了一个简单的'start'控制器,并尝试通过http连接到gi / r5 / start / index.html .....并且我找不到404。
这是我的nginx.conf文件:
user www-data www-data;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37;
passenger_ruby /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/wrappers/ruby;
passenger_app_env production;
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80 default_server;
return 444;
}
server {
listen 80;
#server_name resys.gourmindia.com;
server_name 134.213.29.174;
root /data/www/gi/public/;
index index.html;
passenger_enabled on;
#passenger_root /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37;
#passenger_ruby /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/wrappers/ruby;
# location / {
# try_files $uri $uri/ /index.html;
# }
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/r5(/.*|$) {
alias /data/www/r5/public$1; # <-- be sure to point to 'public'!
passenger_base_uri /r5;
passenger_app_root /data/www/r5;
passenger_document_root data/www/r5/public;
passenger_ruby /home/nexargi/.rvm/gems/ruby-2.4.0/wrappers/ruby;
passenger_enabled on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
这是/opt/ningx/logs/error.log(最后一节 - 我觉得发生了失败)
[ 2017-12-27 18:40:37.0095 15198/7fe1c970e700 Pool2/Pool.h:777 ]: Process (pid=15452, group=/data/www/r5#default) no longer exists! Detaching it from the pool.
App 15463 stdout:
App 15237 stderr: /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:356:in `trap'
App 15237 stderr: :
App 15237 stderr: Invalid argument - SIGKILL
App 15237 stderr: (
App 15237 stderr: Errno::EINVAL
App 15237 stderr: )
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:356:in `block in reset_signal_handlers'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:354:in `each_key'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:354:in `reset_signal_handlers'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:182:in `main_loop'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:161:in `<module:App>'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'
[ 2017-12-27 18:40:42.0077 15198/7fe1c970e700 Pool2/Pool.h:777 ]: Process (pid=15463, group=/data/www/r5#default) no longer exists! Detaching it from the pool.
App 15472 stdout:
App 15237 stderr: /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:356:in `trap'
App 15237 stderr: :
App 15237 stderr: Invalid argument - SIGKILL
App 15237 stderr: (
App 15237 stderr: Errno::EINVAL
App 15237 stderr: )
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:356:in `block in reset_signal_handlers'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:354:in `each_key'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:354:in `reset_signal_handlers'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/lib/phusion_passenger/request_handler.rb:182:in `main_loop'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:161:in `<module:App>'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
App 15237 stderr: from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'
我做错了什么?
我在phusionpassenger.com网站上发现了这个:
https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_ruby
我做了以下事情:
>which passenger-config
/home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/bin/passenger-config
>rvm use 2.4.0
Using /home/nexargi/.rvm/gems/ruby-2.4.0
>/home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/bin/passenger-config --ruby-command
出现以下错误消息:
/home/nexargi/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems.rb:289:in `find_spec_for_exe': can't find gem passenger (>= 0.a) with executable passenger-config (Gem::GemNotFoundException)
from /home/nexargi/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems.rb:308:in `activate_bin_path'
from /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/bin/passenger-config:23:in `<main>'
请注意,ruby 2.4.0是r5 sub-uri所需的ruby。这确实看起来像问题。但是我不知道如何纠正它。
为了绝对肯定我接着做了以下事情:
>rvm use 1.9.3-p484
Using /home/nexargi/.rvm/gems/ruby-1.9.3-p484
>/home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/bin/passenger-config --ruby-command
这给出了预期的正确信息:
passenger-config was invoked through the following Ruby interpreter:
Command: /home/nexargi/.rvm/gems/ruby-1.9.3-p484/wrappers/ruby
Version: ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
To use in Apache: PassengerRuby /home/nexargi/.rvm/gems/ruby-1.9.3-p484/wrappers/ruby
To use in Nginx : passenger_ruby /home/nexargi/.rvm/gems/ruby-1.9.3-p484/wrappers/ruby
To use with Standalone: /home/nexargi/.rvm/gems/ruby-1.9.3-p484/wrappers/ruby /home/nexargi/.rvm/gems/ruby-1.9.3-p484@global/gems/passenger-4.0.37/bin/passenger start
## Notes for RVM users
Do you want to know which command to use for a different Ruby interpreter? 'rvm use' that Ruby interpreter, then re-run 'passenger-config --ruby-command'.
答案 0 :(得分:0)
看来现有网站的乘客是使用RVM gem install等安装的,这不是目前推荐的做事方式。
我发现了这个:
https://www.phusionpassenger.com/library/install/nginx/install/oss/xenial/
我跟着这个,在从RVM内部移走旧乘客后,一切都很好。