V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hustlzp
V2EX  ›  程序员

Nginx+php-fpm,访问http://localhost/phpmyadmin/发现图片全挂了

  •  
  •   hustlzp ·
    hustlzp · 2013-05-10 21:37:19 +08:00 · 4264 次点击
    这是一个创建于 4031 天前的主题,其中的信息可能已经有所发展或是发生改变。
    nginx新手,刚从 apache2+mod_php 转到 nginx+php-fpm...
    nginx是编译的1.5.0,php-fpm也是编译的。
    nginx配置如下:

    server {
    listen 80;

    root /var/www;
    index index.html index.htm;

    server_name localhost;

    location / {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_script_name;

    include fastcgi_params;
    }
    }

    访问http://localhost/phpmyadmin,网站可以正常工作,但发现图片都404了。
    目前在看php-fpm.conf,看是不是里面哪里没配好...
    5 条回复    1970-01-01 08:00:00 +08:00
    barbery
        1
    barbery  
       2013-05-10 22:20:33 +08:00
    擦 你这样肯定不行啊。。。图片都走php-fpm通道了。。。。
    barbery
        2
    barbery  
       2013-05-10 22:24:27 +08:00
    location ~ \.php
    {
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
    include /usr/local/Cellar/nginx/conf/fastcgi_params;
    set $path_info "";
    set $real_script_name $fastcgi_script_name;

    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
    set $real_script_name $1;
    set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME /usr/local/Cellar/nginx/html/$real_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    }

    我的nginx.conf 是这样配的。。。这样在本地开发使用php mvc框架,也不会有pathinfo问题。。。具体路径你可能还要改改
    shiny
        3
    shiny  
       2013-05-10 22:24:30 +08:00
    既然是新手,为什么要编译呢?一键 apt-get/yum 安装好后默认配置都足够清晰,service 启动脚本也给你写好了。
    php 的解析应该是 location ~ \.php$ 里的。
    glancesx
        4
    glancesx  
       2013-05-10 22:51:09 +08:00
    location ~ .*\.php?$
    {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    hustlzp
        5
    hustlzp  
    OP
       2013-05-10 23:01:44 +08:00
    @shiny 懂了。。。sb了。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4840 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 01:14 · PVG 09:14 · LAX 18:14 · JFK 21:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.