设为首页收藏本站

LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区!

 找回密码
 注册

用新浪微博连接

一步搞定

QQ登录

只需一步,快速开始

查看: 274|回复: 1

[nginx] root路径的问题 [复制链接]

Rank: 4

签到
6
注册时间
2012-1-15
最后登录
2012-2-14
在线时间
3 小时
阅读权限
50
积分
743
帖子
1
主题
1
精华
0
UID
17348
发表于 2012-2-4 13:45:15 |显示全部楼层
本帖最后由 同学仔 于 2012-2-4 13:46 编辑

配置文件如下:
  1. #user  nobody;
  2. worker_processes  1;
  3. pid        logs/nginx.pid;

  4. events {
  5.     worker_connections  1024;
  6.     use                 epoll;
  7. }

  8. http {
  9.     include       mime.types;
  10.     default_type  application/octet-stream;

  11.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  12.                       '$status $body_bytes_sent "$http_referer" '
  13.                       '"$http_user_agent" "$http_x_forwarded_for"';

  14.     access_log  logs/access.log  main;

  15.     sendfile        on;
  16.     #tcp_nopush     on;

  17.     #keepalive_timeout  0;
  18.     keepalive_timeout  65;

  19.     #gzip  on;

  20.     server {
  21.         listen       80;
  22.         server_name  localhost;

  23.         #charset koi8-r;

  24.         #access_log  logs/host.access.log  main;

  25.         location / {
  26.             root   html;
  27.             index  index.html index.htm;
  28.         }

  29.         error_page  404              /404.html;

  30.         # redirect server error pages to the static page /50x.html
  31.         #
  32.         error_page   500 502 503 504  /50x.html;
  33.         location = /50x.html {
  34.             root   html;
  35.         }

  36.         location ~ \.php$ {
  37.             root          /var/www/cgi-bin;
  38.             fastcgi_pass   127.0.0.1:9000;
  39.             fastcgi_index  index.php;
  40.             fastcgi_param  SCRIPT_FILENAME  /var/www/cgi-bin$fastcgi_script_name;
  41.             include        fastcgi_params;
  42.         }

  43.         location /cgi/ {
  44.             alias          /var/www/html/;
  45.             index          index.html;
  46.             error_log      on;
  47.         }
  48.     }

  49. }
复制代码
问题如下:
phpMyAdmin文件夹放在/var/www/中去
访问的时候,ip/phpMyAdmin/index.php能打开但是图片却不能显示,具体的问题是图片的根路径是使用/var/www/,而不是/var/www/cgi-bin/
感觉location ~ \.php$中的root不起作用。请问如何解决。

Rank: 6Rank: 6

注册时间
2012-3-13
最后登录
2012-4-9
在线时间
4 小时
阅读权限
70
积分
1232
帖子
3
主题
0
精华
0
UID
18642
发表于 2012-3-14 12:15:34 |显示全部楼层
本帖最后由 ecshop爱好者 于 2012-3-14 12:20 编辑
  1. #user  nobody;
  2. worker_processes  1;
  3. pid        logs/nginx.pid;

  4. events {
  5.     worker_connections  1024;
  6.     use                 epoll;
  7. }

  8. http {
  9.     include       mime.types;
  10.     default_type  application/octet-stream;

  11.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  12.                       '$status $body_bytes_sent "$http_referer" '
  13.                       '"$http_user_agent" "$http_x_forwarded_for"';

  14.     access_log  logs/access.log  main;

  15.     sendfile        on;
  16.     #tcp_nopush     on;

  17.     #keepalive_timeout  0;
  18.     keepalive_timeout  65;

  19.     #gzip  on;

  20.     server {
  21.         listen       80;
  22.         server_name  localhost;

  23.         #charset koi8-r;

  24.         #access_log  logs/host.access.log  main;
  25.         root          /var/www/cgi-bin;
  26.         index index.php index.html index.htm

  27.         
  28.         location ~ \.php$ {
  29.            
  30.             fastcgi_pass   127.0.0.1:9000;
  31.             fastcgi_index  index.php;
  32.             fastcgi_param  SCRIPT_FILENAME  /var/www/cgi-bin$fastcgi_script_name;
  33.             include        fastcgi_params;
  34.         }

  35.         
  36.     }

  37. }
复制代码
这样看下

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

IT运维专家网感谢红之盟网络提供带宽支持

合作联系: QQ:67888954/MSN:cnseek@msn.com/mail:netseek@linuxtone.org

Archiver|手机版|感谢所有关心和支持过LinuxTone的朋友们 转载本站内容请注明原作者名及出处 ( 京ICP备08103151 )   |

GMT+8, 2012-5-23 10:18 , Processed in 0.217027 second(s), 12 queries , Memcache On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部