V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
coolicer
V2EX  ›  Linux

有没有ubuntu下编译nginx的教程,找了很多都是用源安装。我用源安装也不懂配置

  •  
  •   coolicer · 2013-11-18 10:34:17 +08:00 · 3577 次点击
    这是一个创建于 3829 天前的主题,其中的信息可能已经有所发展或是发生改变。
    访问 index.php,把文件给我下载了。难道是没有开启解析PHP的组件吗?
    第 1 条附言  ·  2013-11-18 15:03:06 +08:00
    终于可以了,把
    fastcgi_pass 127.0.0.1:9000;
    换成
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    18 条回复    1970-01-01 08:00:00 +08:00
    nonozone
        1
    nonozone  
       2013-11-18 10:37:23 +08:00
    应该是这样
    alexrezit
        2
    alexrezit  
       2013-11-18 10:38:12 +08:00 via iPhone
    RTFM.
    coolicer
        3
    coolicer  
    OP
       2013-11-18 10:39:10 +08:00
    @alexrezit 我把之前的配置还原了,现在是403
    Lax
        4
    Lax  
       2013-11-18 10:43:29 +08:00
    nginx不内置php解析。再看看php-fpm。
    coolicer
        5
    coolicer  
    OP
       2013-11-18 10:53:47 +08:00
    server {
    listen 8080 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /home/httpd;
    index index.html index.htm;

    server_name localhost;

    location ~ \.php$ {

    root /home/httpd;
    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    coolicer
        6
    coolicer  
    OP
       2013-11-18 10:54:09 +08:00
    @Lax 我的配置
    AstroProfundis
        7
    AstroProfundis  
       2013-11-18 10:56:15 +08:00
    你9000端口上有php-fcgi进程么?用httpd的话应该把端口改掉,比如默认的80改成81,然后nginx里面 proxy_pass http://127.0.0.1:81;

    如果是装了 php5-fpm 然后启动就是 fastcgi_pass 127.0.0.1:9000;
    coolicer
        8
    coolicer  
    OP
       2013-11-18 10:58:56 +08:00
    @AstroProfundis 没有9000进程,我是用源安装php和Nginx
    F0ur
        9
    F0ur  
       2013-11-18 11:00:49 +08:00
    php-fpm没开启吧。。
    AstroProfundis
        10
    AstroProfundis  
       2013-11-18 11:03:16 +08:00
    @coolicer 那你显然要启动了后端才行啊...不过配置正确的话后端没启动应该是502错误,你试试改成 proxy_pass 到你的php-cgi端口
    jtn007
        11
    jtn007  
       2013-11-18 11:06:31 +08:00
    我跑rails,nginx是用passenger装的。。。
    barbery
        12
    barbery  
       2013-11-18 12:34:37 +08:00
    ubuntu 上还要 sudo apt-get install php5-fpm
    sandtears
        13
    sandtears  
       2013-11-18 13:24:19 +08:00
    需要用fastcgi_pass转发给php5-fpm吧
    hfcorriez
        14
    hfcorriez  
       2013-11-19 00:41:46 +08:00
    看了你的解决方案,是你fpm配置监听方式的问题。

    fpm分为端口监听和unix socket监听方式,前者对应你的IP端口,后者对应文件路径,nginx配置一致才能解决问题!
    msg7086
        15
    msg7086  
       2013-11-19 05:10:36 +08:00
    包管理默认的PHP-FPM的配置在 /etc/php5/fpm/pool.d/www.conf 里面可以改监听方式。

    只要nginx和www.conf两者的设定相同就不会出问题
    coolicer
        16
    coolicer  
    OP
       2013-11-19 08:46:03 +08:00
    @hfcorriez 我也觉得有问题
    coolicer
        17
    coolicer  
    OP
       2013-11-19 08:46:28 +08:00
    @msg7086 谢谢,我刚接触,搞了好久才可以的。
    coolicer
        18
    coolicer  
    OP
       2013-11-19 14:01:39 +08:00
    @msg7086 我在www.conf 开了允许127.0.0.1也不行。还是要用回socket监听,我是在源安装的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   995 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:22 · PVG 04:22 · LAX 13:22 · JFK 16:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.