• 赞,顶

  • #6 楼 @Guest 有意跳槽不?

  • #16 楼 @Rei 多谢 rei,连上了 @huacnlee 找时间把环境用户权限好好学学

  • 还有个怪事,我有两个域名 a.com,b.com,pat.a.com,pat.b.com 都解析到这个 ip,但是 nginx 里只配 pat.a.com,两个访问都是 403,也都导向 root 目录了,nginx 没过滤我的域名?

  • #11 楼 @ruohanc nginx 配置没动过

    cat /etc/nginx/nginx.conf 
    user www-data;
    worker_processes 4;
    pid /var/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;
            # server_tokens off;
    
            # server_names_hash_bucket_size 64;
            # server_name_in_redirect off;
    
            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_vary on;
            # gzip_proxied any;
            # gzip_comp_level 6;
            # gzip_buffers 16 8k;
            # gzip_http_version 1.1;
            # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
            ##
            # nginx-naxsi config
            ##
            # Uncomment it if you installed nginx-naxsi
            ##
    
            # include /etc/nginx/naxsi_core.rules;
    
            ##
            # 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 /usr/bin/ruby;
    
            ##
            # Virtual Host Configs
            ##
    
            include /etc/nginx/conf.d/*.conf;
            include /etc/nginx/sites-enabled/*;
    }
    
    
    # mail {
    #       # See sample authentication script at:
    #       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    # 
    #       # auth_http localhost/auth.php;
    #       # pop3_capabilities "TOP" "USER";
    #       # imap_capabilities "IMAP4rev1" "UIDPLUS";
    # 
    #       server {
    #               listen     localhost:110;
    #               protocol   pop3;
    #               proxy      on;
    #       }
    # 
    #       server {
    #               listen     localhost:143;
    #               protocol   imap;
    #               proxy      on;
    #       }
    # }
    

    按文档加的

    cat /etc/nginx/sites-enabled/example.com.conf 
    server {
        listen 80 default;
        #listen 3000;
        server_name pattest.domain1.com;
        root /var/www/pattest.domain1.com/pat/public;
        passenger_ruby /home/lpxiao/.rvm/rubies/ruby-2.1.0/bin/ruby;
        passenger_enabled on;
    }
    
  • #11 楼 @ruohanc

    1. shell ps -ef| grep nginx root 45240 1 0 21:02 ? 00:00:00 nginx: master process /usr/sbin/nginx www-data 45241 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45242 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45243 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45244 45240 0 21:02 ? 00:00:00 nginx: worker process lpxiao 45454 43362 0 21:23 pts/1 00:00:00 grep --color=auto nginx
    cat /etc/nginx/nginx.conf | grep user
    user www-data;
    

    2.

    sudo -u www-data ls /var/www/pattest.domain1.com/pat/public/
    [sudo] password for lpxiao: 
    404.html  422.html  500.html  assets  favicon.png  robots.txt
    

    3.

    sudo chown www-data: -R public/
    [sudo] password for lpxiao: 
    
    ll | grep public
    drwxr-xr-x  3 www-data www-data  4096 May 24 21:11 public/
    

    log,偶发报 favicon.ico,不知啥原因

    2014/05/24 21:33:10 [error] 45241#0: *12 open() "/var/www/pattest.domain1.com/pat/public/favicon.ico" failed (2: No such file or directory), client: 123.114.36.75, server: pattest.domain1.com, request: "GET /favicon.ico HTTP/1.1", host: "pattest.domain2.cn"
    2014/05/24 21:33:44 [error] 45241#0: *16 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    2014/05/24 21:34:38 [error] 45241#0: *16 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    2014/05/24 21:35:49 [error] 45241#0: *18 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    
  • 来结贴: 今天使用 root 登录 pg 失败同样报错 PG::ConnectionBad (FATAL: Peer authentication failed for user "lpxiao" 增加 -h 之后成功登录 故在 database.yml 的 host 填写 localhost 后正常运行 又碰到新问题,原因未研究

  • #8 楼 @ruohanc 再看下?

    1. 运营用户是 user www-data;;
    2. 可以正常 ls
    3. 没有用 public 下面如果有 index.html 是可以正常访问的,看 nginx 日志就是 public 无权限,public +777 和改 owner 都没有用
  • #5 楼 @Rei 能经验的给一些调试思路吗?现在是加 autoindex on;能正常访问目录;增加 Index.html 文件也能访问到,同时如果用的是另一个非 nginx conf 中配置的域名也能访问到

  • #3 楼 @Rei drwxr-xr-x 15 lpxiao lpxiao 4096 May 23 22:33 pat drwxr-xr-x 2 lpxiao lpxiao 4096 May 24 16:29 public 基本上是按照“Ubuntu 12.04 上使用 Nginx Passenger 部署 Ruby on Rails”操作的,不同之处是 pat 这个应用之前已经可以通过 rails s 启动,没有 bundle

  • #3 楼 @Rei 终于等来啦,public 和应用根目录/var/www/pattest.domain1.com/pat 的拥有者都是 lpxiao

  • 论坛,stackoverflow 的 case 都看过了,都没解决。。

  • 补充:在 public 下放/index.html 能正常访问到

  • @Rei 求指导,搜几天了,实在解决不了。。

  • 同样碰到 403 问题了,请@Rei @jialezhang 帮看看 直接 rails s 启动可以正常 ip 访问 感觉 server_name pattest.domain1.com;并未生效,通过http://pattest.domain1.com:3000/http://pattest.domain2.com:3000/访问都是403或者

    配置: cat /etc/nginx/sites-enabled/example.com.conf server { #listen 80 default; listen 3000; server_name pattest.domain1.com; # 这里填写你真实域名 root /var/www/pattest.domain1.com/pat/public; passenger_ruby /home/lpxiao/.rvm/rubies/ruby-2.1.0/bin/ruby; passenger_enabled on; }

    nginx log: 2014/05/23 23:04:36 [error] 35484#0: *4 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com:3000"

    ror public: drwxr-xr-x 3 lpxiao lpxiao 4096 May 23 22:33 public

  • #2 楼 @ailen @pynix 我用的 rvmsudo,有 root 权限而非 root 用户,另外 lpxiao 是有 pg 权限的,正文已说明,绑定 1024 以上端口一切正常,我怀疑是 rvmsudo 导致一些环境没有 load

  • #12 楼 @sunday35034 多谢,按这个步骤搞下,sunday 当初怎么处理的 min.css min.js,直接用的?

  • #8 楼 @naitnix 有站点链接不?

  • #6 楼 @leekelby @sunday35034 多谢指点,没有看到未压缩 css,ace 都是带 min 的,暂定还是一步步来,先学习 ruby-china 的前端展示

  • 哪家云有 nosql 数据库? at 2014年04月15日

    阿里云 OTS,OCS 腾讯云 CMEM Ucloud UMem

    OCS CMEM UMem 较贵,适合热点数据

  • wechat-rails 微信 DSL for ruby at 2014年04月14日

    赞,有机会用用

  • #2 楼 @chunlea 稍花哨,不过 admin 类没有找到更好的资源

  • #1 楼 @ericguo 希望灵活性高点易于学习,eric 觉得重写 html 靠谱不,有没有更好的方案?

  • #49 楼 @Victor 如何将买来的前端模版整合到 rails?wrap 上下了一个发现和 rails 应用差异很大,是否需要自己抠出来 layout 和 assets?

  • 购买 wrapbootstrap.com at 2014年04月12日

    #7 楼 @xiaoniuniu 最后怎么用起来的?同遇到。。

  • 无法删帖 at 2014年04月07日

    新手上路中,打算先找个基于 bootstrap 的模版入门

  • 愣,在 lz 大学同学后面发现了 ustc..

  • #2 楼 @blacktulip 请问定时任务如何调用 rails 中的 controller,model 方法?

  • #7 楼 @small_fish__ 用的啥方法?Net::POP3?