[英]Rails application Error with Nginx/Passenger
I just made the Capistrano deployment to a server with Linux Server (14.04), Nginx, PHP5-FPM (for phpMyAdmin), MySQL, Passenger. 我刚刚将Capistrano部署到Linux服务器(14.04),Nginx,PHP5-FPM(用于phpMyAdmin),MySQL,Passenger的服务器上。
Everything is fine, but when I try to access the rails app from the browser I get error. 一切都很好,但当我尝试从浏览器访问rails应用程序时,我收到错误。 I went to check the Log Nginx and I get the following:
我去检查Log Nginx,我得到以下内容:
App 15973 stdout:
App 15973 stderr: [passenger_native_support.so] trying to compile for the current user (deploy) and Ruby interpreter...
App 15973 stderr: (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)
App 15973 stderr: Warning: compilation didn't succeed. To learn why, read this file:
App 15973 stderr: /tmp/passenger_native_support-a97tab.log
App 15973 stderr: [passenger_native_support.so] not downloading because passenger wasn't installed from a release package
App 15973 stderr: [passenger_native_support.so] will not be used (can't compile or download)
App 15973 stderr: --> Passenger will still operate normally.
App 16021 stdout:
Then: 然后:
$cat /tmp/passenger_native_support-a97tab.log
# current user is: deploy
# mkdir -p /usr/lib/buildout/ruby/ruby-2.2.1-x86_64-linux
Encountered permission error, trying a different directory...
-------------------------------
# mkdir -p /home/deploy/.passenger/native_support/5.0.26/ruby-2.2.1-x86_64-linux
# cd /home/deploy/.passenger/native_support/5.0.26/ruby-2.2.1-x86_64-linux
# /home/deploy/.rbenv/versions/2.2.1/bin/ruby /usr/lib/src/ruby_native_extension/extconf.rb
/home/deploy/.rbenv/versions/2.2.1/bin/ruby: No such file or directory -- /usr/lib/src/ruby_native_extension/extconf.rb (LoadError)
What's wrong with it? 它出什么问题了?
This is my Nginx Default file: 这是我的Nginx默认文件:
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
# root /usr/share/nginx/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php index.nginx-debian.html;
server_name _;
passenger_enabled on;
rails_env development;
root /home/deploy/highschool/current/public;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
And my Nginx.conf 还有我的Nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby;
# passenger_ruby /usr/bin/passenger_free_ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
I use RBENV for Ruby versions. 我将RBENV用于Ruby版本。
Sorry for my English. 对不起我的英语不好。
I found the solution. 我找到了解决方案。
In my server, I ran the following command into my Rails App: $ passenger-config build-native-support
. 在我的服务器中,我将以下命令运行到我的Rails应用程序中:
$ passenger-config build-native-support
。 That compiled correctly and show me the really path of ruby_native_extension/extconf.rb
or ruby_native_extension
directory. 这正确编译并向我展示了
ruby_native_extension/extconf.rb
或ruby_native_extension
目录的真正路径。
I only create a symbolic link from /usr/lib/src/
to ruby_native_extension
directory and restart Nginx. 我只创建一个从
/usr/lib/src/
到ruby_native_extension
目录的符号链接并重新启动Nginx。
When I did that the error disappeared , but then the Login ( devise ) did not work , always got the 404 error . 当我这样做错误消失,但然后登录(设计)不起作用,总是得到404错误。 So, (if in any case happens) I added some lines specifically for the route sign_in.
所以,(如果在任何情况下发生)我专门为路线sign_in添加了一些线。
In my Nginx Default file I added the following: 在我的Nginx默认文件中,我添加了以下内容:
location /users/sign_in {
passenger_enabled on
}
And edit: 并编辑:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
passenger_enabled on
try_files $uri $uri/ =404;
}
And with these changes, my rails application is running. 通过这些更改,我的rails应用程序正在运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.