AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 424056
Accepted
New Alexandria
New Alexandria
Asked: 2012-09-04 21:31:01 +0800 CST2012-09-04 21:31:01 +0800 CST 2012-09-04 21:31:01 +0800 CST

如何设置 nginx 以使用 rails(unicorn/passenger) 和 php-fpm 为虚拟主机提供服务

  • 772

我想在一个实例上为多个站点提供服务。

我安装了 nginx、php-fpm 和一个 Rails 应用程序。我使用这样的网站来指导我。

我将 php-fpm 配置为监听本地套接字

listen = /var/run/php-fpm/php-fpm.sock

我用多个主机配置 ngnix:

include /etc/nginx/conf.d/*.conf

我有几个网站 php conf 文件,比如/etc/nginx/conf.d/site1.conf

server {
    listen 80; 
    server_name site1.com www.site1.com;

    root /var/www/site1;

    access_log /var/log/nginx/site1.com-access.log;
    error_log /var/log/nginx/site1.com-error.log;

    location / { 
        index index.html index.php;
    }   
    location ~ \.php$ {
        fastcgi_pass        unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index       index.php;
        include             fastcgi_params;
        fastcgi_param       PATH_INFO $fastcgi_script_name;
        fastcgi_param       SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }       
}

和 Rails 站点配置文件,例如

upstream rails {
    server 127.0.0.1:3000;
}

server {
    listen 80;
    server_name site2.com www.site2.com;

    access_log /var/log/nginx/site2.com-access.log;
    error_log /var/log/nginx/site2.com-error.log;

    root /var/www/site2;

    location / {
        proxy_pass                       http://rails;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $host;
        proxy_set_header X-Url-Scheme    $scheme;
    }
}

我有一个独角兽 Rails 服务器运行通过rails s -p 3000

然而,没有网站出现site1.comor site2.com。我可以到达 rails 站点www.site2.com:3000

怎么了?我花了 2 天(将近 30 小时)尝试许多不同的博客、SO / SF 问题等。请分享您的见解或答案。

编辑 1:当我尝试访问任何一个站点时都没有创建日志条目。就像请求永远不会进来一样。

nginx
  • 1 1 个回答
  • 1328 Views

1 个回答

  • Voted
  1. Best Answer
    New Alexandria
    2012-09-09T17:38:48+08:002012-09-09T17:38:48+08:00

    始终检查您的防火墙/代理/传入端口。

    上述配置文件中的所有内容都运行良好。问题是端口 80 未对入站流量开放。

    • 0

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve