如何设置nginx以允许在ubuntu 12.04上使用/ suburi进行访问? [英] How to setup nginx to allow access with /suburi on ubuntu 12.04?

查看:130
本文介绍了如何设置nginx以允许在ubuntu 12.04上使用/ suburi进行访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设置一个nginx Web服务器,以便在我们的rails 3.1 app中允许/ suburi访问(例如访问URL: http://www.railapp.com/subdomain )。这里的subrui名称是byop。我们的rails文件根子目录位于/ var / www /。 suburi byop位于/ var / www / byop。以下是我们在成功部署rails之后所做的事情:

We are setting up a nginx web server to allow /suburi access in our rails 3.1 app (such as access URL: http://www.railapp.com/subdomain). The subrui name here is byop. Our rails document root subdir is at /var/www/. The suburi byop is at /var/www/byop. Here is what we did after successful rails deployment:


  1. 设置nginx.conf:

  1. Setup the nginx.conf:

服务器{
听80;
server_name 154.248.209.181;
root / var / www /;
passenger_enabled on;
rails_env production;
passenger_base_uri / byop;
}

server { listen 80; server_name 154.248.209.181; root /var/www/; passenger_enabled on; rails_env production; passenger_base_uri /byop; }

在/ var / www下创建符号链接如下:

Create symbolic link under /var/www as following:

ln -s / var / www / byop / current / public / var / www / byop

ln -s /var/www/byop/current/public /var/www/byop

nginx停止并重新启动。但是,对于 http://154.248.209.181/byop 显示403禁止页面

nginx was stop and restarted. However 403 Forbidden page shows up for http://154.248.209.181/byop

我们检查了/ var / www下的符号链接,并且没有列出链接(只有byop子目录)。这是ls -li的输出:

We checked the symbolic link under /var/www and there is no link listed (only the byop subdir). Here is the output of ls -li:

ubuntu@ip-10-152-95-60:/var/www$ ls -li
total 4
9296 drwxrwsr-x 4 ubuntu www-data 4096 May  6 03:12 byop

上面的设置有什么问题?非常感谢。

What's wrong with our setup above? Thanks so much.

推荐答案

我们发现的问题是在步骤2中创建符号链接。 subdir的名称和符号链接的名称是相同的。使用不同的符号链接名称后,问题解决了。这是工作副本:

The problem we found is with the step 2 to create the symlink. The name of the subdir and the name of symbolic link are the same. After using different symlink name, the problem solved. Here is the working copy:

1. Setup the nginx.conf:

server { 
    listen 80; 
    server_name 154.248.209.181; 
    root /var/www/; 
    passenger_enabled on; 
    rails_env production; 
    passenger_base_uri /by; 
 }

2. Create symlink under /var/www as following:

ln -s /var/www/byop/current/public /var/www/by

然后 http://154.248.209.181/by 显示页面。

这篇关于如何设置nginx以允许在ubuntu 12.04上使用/ suburi进行访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆