如何将Apache的"AllowOverride all"转换为nginx [英] How to convert Apache's `AllowOverride all` to nginx
问题描述
我有一个Apache2& Rails应用程序的乘客站点,该站点使用以下配置:
I have an Apache2 & Passenger site for Rails app, that uses following configuration:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/site/public
<Directory /var/www/site/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
nginx&是否具有等效项?客运站点?当前,nginx用404
响应所有形式为{ID}/action
的请求.这是Nginx conf的相关部分:
Is there an equivalent for nginx & Passenger site? Currently nginx responds to all requests in form {ID}/action
with 404
. Here's the relevant part of nginx conf:
location / {
passenger_app_root /var/www/site;
passenger_document_root /var/www/site/public;
passenger_enabled on;
try_files $uri $uri/ =404;
}
应用程序中没有.htaccess
文件.
推荐答案
此处是旅客作者. Nginx中没有"AllowOverride all"的等效项,您也不需要它.您需要做的是一个虚拟主机块,其根"指向应用程序的公共"目录,并启用passenger_enabled":
Passenger author here. There is no equivalent for 'AllowOverride all' in Nginx, and you don't need it either. All you need is a virtual host block with the 'root' pointing to your app's 'public' directory, and 'passenger_enabled on':
server {
listen 80;
server_name www.example.com;
root /var/www/site/public;
passenger_enabled on;
}
...如官方乘客文档的部署说明所述.
passenger_app_root
和passenger_document_root
.不需要try_files
也是因为旅客 自动通过Nginx为您提供静态文件.
passenger_app_root
and passenger_document_root
are automatically inferred for you from root
. There is no need for try_files
either because Passenger automatically serves static files for you through Nginx.
您应该阅读官方文档.
这篇关于如何将Apache的"AllowOverride all"转换为nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!