【发布时间】:2015-01-24 10:39:37
【问题描述】:
我想像这样从同一个 nginx 提供 rails、php 和静态 html:
- example.com - 点击 php
- example.com/app - 命中轨道
- example.com/static - 点击静态
这种情况可能是暂时的(可能会在某个时候拆分到多个服务器),所以我想避免更改代码(将范围或命名空间添加到 rails 路由 - 我希望 rails 处理“example.com/应用程序”作为根)。
我的 nginx.conf 应该是什么样的?
我使用这个page from the passenger docs 作为参考并尝试了这样的事情:
server {
server_name example.com;
listen 80;
root /var/www/php;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
location ~ ^/app(/.*|$) {
alias /var/www/rails/current/public$1;
access_log /var/www/rails/current/log/access.log;
error_log /var/www/rails/current/log/error.log;
passenger_base_uri /app;
passenger_app_root /var/www/rails;
passenger_document_root /var/www/rails/currnet/public;
passenger_enabled on;
passenger_app_env production;
passenger_friendly_error_pages on;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.5@app/wrappers/ruby;
client_max_body_size 4G;
keepalive_timeout 10;
}
}
但我得到“找不到”
【问题讨论】:
标签: php ruby-on-rails nginx