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

2013-05-10 21:37:19 +08:00
 hustlzp
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,看是不是里面哪里没配好...
4270 次点击
所在节点    程序员
5 条回复
barbery
2013-05-10 22:20:33 +08:00
擦 你这样肯定不行啊。。。图片都走php-fpm通道了。。。。
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
2013-05-10 22:24:30 +08:00
既然是新手,为什么要编译呢?一键 apt-get/yum 安装好后默认配置都足够清晰,service 启动脚本也给你写好了。
php 的解析应该是 location ~ \.php$ 里的。
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
2013-05-10 23:01:44 +08:00
@shiny 懂了。。。sb了。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/68431

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX