VPS侦探论坛

 找回密码
 注册
查看: 12118|回复: 8

再问path info问题,还没有搞好,老大帮看一下

[复制链接]
发表于 2010-8-8 20:59:38 | 显示全部楼层 |阅读模式

要配置支持 path_info  以前问过这个问题 按老大给的nginx官方的方法 https://bbs.vpser.net/thread-1468-1-1.html
同时也google了 好多
但我咋就搞不好呢,哪里错了,望给指点一下 代码如下

conf/nginx.conf的代码
  1. user  www www;

  2. worker_processes 4;

  3. error_log  /home/wwwroot/logs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 8m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name www.testsite.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;

  45.                 location ~ ^(.+\.php)(.*)$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;

  48.                                 fastcgi_index index.php;
  49.             fastcgi_split_path_info ^(.+\.php)(.*)$;
  50. fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
  51. fastcgi_param PATH_INFO $fastcgi_path_info;
  52. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

  53.       
  54.                               
  55.                                 include fcgi.conf;
  56.                         }


  57.                 location /status {
  58.                         stub_status on;
  59.                         access_log   off;
  60.                 }

  61.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  62.                         {
  63.                                 expires      30d;
  64.                         }

  65.                 location ~ .*\.(js|css)?$
  66.                         {
  67.                                 expires      12h;
  68.                         }

  69.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  70.              '$status $body_bytes_sent "$http_referer" '
  71.              '"$http_user_agent" $http_x_forwarded_for';
  72.                 access_log  /home/wwwroot/logs/access.log  access;
  73.         }
  74. include vhost/*.conf;
  75. }
复制代码
/vhost/my.testsite.com.conf的代码
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name my.testsite.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/my.testsite.com;

  7.                 include none.conf;
  8.                 location ~ .*\.(php|php5)?$
  9.                         {
  10.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  11.                                 fastcgi_index index.php;
  12.                                 include fcgi.conf;
  13.                         }

  14.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  15.                         {
  16.                                 expires      30d;
  17.                         }

  18.                 location ~ .*\.(js|css)?$
  19.                         {
  20.                                 expires      12h;
  21.                         }

  22.                 access_log off;
  23.         }
复制代码
另一个虚拟主机的 conf文件
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name my2.testsite.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/my2.testsite.com;

  7.                 include none.conf;
  8.                 location ~ ^(.+\.php)(.*)$
  9.                         {
  10.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;

  11.                                 fastcgi_index index.php;
  12.             fastcgi_split_path_info ^(.+\.php)(.*)$;
  13. fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
  14. fastcgi_param PATH_INFO $fastcgi_path_info;
  15. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

  16.                                 fastcgi_index index.php;
  17.                                 include fcgi.conf;
  18.                         }

  19.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  20.                         {
  21.                                 expires      30d;
  22.                         }

  23.                 location ~ .*\.(js|css)?$
  24.                         {
  25.                                 expires      12h;
  26.                         }

  27.                 access_log off;
  28.         }
复制代码
可还是不行,老大帮看一下 那里错了

[ 本帖最后由 孤独剑客 于 2010-8-9 18:14 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-8-8 21:00:56 | 显示全部楼层


  1. [root@libo vhost]# /root/lnmp restart
  2. =========================================================================
  3. Manager for LNMP V0.4  ,  Written by Licess
  4. =========================================================================
  5. LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
  6. This script is a tool to Manage status of lnmp
  7. For more information please visit http://www.lnmp.org

  8. Usage: /root/lnmp {start|stop|reload|restart|kill|status}
  9. =========================================================================
  10. Reload LNMP...
  11. Reload Nginx configure...
  12. the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  13. configuration file /usr/local/nginx/conf/nginx.conf test is successful
  14. Nginx program is reloding!
  15. Shutting down MySQL.[  OK  ]
  16. Starting MySQL.[  OK  ]
  17. Shutting down php_fpm . done
  18. Starting php_fpm  done
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-9 15:42:31 | 显示全部楼层

自己顶一下 不顶就陈了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-8-9 15:57:36 | 显示全部楼层



原帖由 孤独剑客 于 2010-8-8 21:00 发表
[root@libo vhost]# /root/lnmp restart
=========================================================================
Manager for LNMP V0.4  ,  Written by Licess
=========================================== ...

我看不出 那里错了 不好意思
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-9 17:12:13 | 显示全部楼层

在顶一下 等斑竹回复 呵呵

军哥运维代购:http://shop63846532.taobao.com/

发表于 2010-8-9 20:15:07 | 显示全部楼层

回复 1# 的帖子


添加的太生硬了。。。
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;  //这个在原来的配置中已经有了,而且其他的/path/to/php 要替换为路径。只填加下面的填加到fcgi.conf中就可以了。
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
 楼主| 发表于 2010-8-13 12:34:42 | 显示全部楼层

折腾了好几天,又重装了系统,还是么有支持下面是代码

fcgi.conf
  1. [root@libo conf]# cat fcgi.conf
  2. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  3. fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

  4. fastcgi_param PATH_INFO $fastcgi_path_info;
  5. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

  6. fastcgi_param  QUERY_STRING       $query_string;
  7. fastcgi_param  REQUEST_METHOD     $request_method;
  8. fastcgi_param  CONTENT_TYPE       $content_type;
  9. fastcgi_param  CONTENT_LENGTH     $content_length;

  10. fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  11. fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  12. fastcgi_param  REQUEST_URI        $request_uri;
  13. fastcgi_param  DOCUMENT_URI       $document_uri;
  14. fastcgi_param  DOCUMENT_ROOT      $document_root;
  15. fastcgi_param  SERVER_PROTOCOL    $server_protocol;

  16. fastcgi_param  REMOTE_ADDR        $remote_addr;
  17. fastcgi_param  REMOTE_PORT        $remote_port;
  18. fastcgi_param  SERVER_ADDR        $server_addr;
  19. fastcgi_param  SERVER_PORT        $server_port;
  20. fastcgi_param  SERVER_NAME        $server_name;

  21. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  22. fastcgi_param  REDIRECT_STATUS    200;
  23. [root@libo conf]#
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-8-13 13:15:46 | 显示全部楼层

按 熊哥的提示修改的 fcgi.conf

  1. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  2. fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

  3. fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
  4. fastcgi_param SCRIPT_NAME $real_script_name;
  5. fastcgi_param PATH_INFO $path_info;

  6. fastcgi_param  QUERY_STRING       $query_string;
  7. fastcgi_param  REQUEST_METHOD     $request_method;
  8. fastcgi_param  CONTENT_TYPE       $content_type;
  9. fastcgi_param  CONTENT_LENGTH     $content_length;

  10. #fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  11. #fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  12. fastcgi_param  REQUEST_URI        $request_uri;
  13. fastcgi_param  DOCUMENT_URI       $document_uri;
  14. fastcgi_param  DOCUMENT_ROOT      $document_root;
  15. fastcgi_param  SERVER_PROTOCOL    $server_protocol;

  16. fastcgi_param  REMOTE_ADDR        $remote_addr;
  17. fastcgi_param  REMOTE_PORT        $remote_port;
  18. fastcgi_param  SERVER_ADDR        $server_addr;
  19. fastcgi_param  SERVER_PORT        $server_port;
  20. fastcgi_param  SERVER_NAME        $server_name;

  21. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  22. fastcgi_param  REDIRECT_STATUS    200;
  23. [root@libo conf]#
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2010-8-13 14:14:26 | 显示全部楼层

把nginx.conf 和虚拟主机的.conf 还有 fcgi.conf 都加上了



nginx.conf的
  1. [root@libo conf]# cat nginx.conf
  2. user  www www;

  3. worker_processes 1;

  4. error_log  /home/wwwroot/logs/nginx_error.log  crit;

  5. pid        /usr/local/nginx/logs/nginx.pid;

  6. #Specifies the value for maximum file descriptors that can be opened by this

  7. process.
  8. worker_rlimit_nofile 51200;

  9. events
  10.         {
  11.                 use epoll;
  12.                 worker_connections 51200;
  13.         }

  14. http
  15.         {
  16.                 include       mime.types;
  17.                 default_type  application/octet-stream;

  18.                 server_names_hash_bucket_size 128;
  19.                 client_header_buffer_size 32k;
  20.                 large_client_header_buffers 4 32k;
  21.                 client_max_body_size 8m;

  22.                 sendfile on;
  23.                 tcp_nopush     on;

  24.                 keepalive_timeout 60;

  25.                 tcp_nodelay on;

  26.                 fastcgi_connect_timeout 300;
  27.                 fastcgi_send_timeout 300;
  28.                 fastcgi_read_timeout 300;
  29.                 fastcgi_buffer_size 64k;
  30.                 fastcgi_buffers 4 64k;
  31.                 fastcgi_busy_buffers_size 128k;
  32.                 fastcgi_temp_file_write_size 256k;

  33.                 gzip on;
  34.                 gzip_min_length  1k;
  35.                 gzip_buffers     4 16k;
  36.                 gzip_http_version 1.0;
  37.                 gzip_comp_level 2;
  38.                 gzip_types       text/plain application/x-javascript

  39. text/css application/xml;
  40.                 gzip_vary on;

  41.                 #limit_zone  crawler  $binary_remote_addr  10m;

  42. server
  43.         {
  44.                 listen       80;
  45.                 server_name li.testsite.com;
  46.                 index index.html index.htm index.php;
  47.                 root  /home/wwwroot;

  48.                 location ~ .*\.(php|php5)?$
  49.                         {
  50.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  51.                                 fastcgi_index index.php;
  52.                                 include fcgi.conf;
  53.                         }

  54.                 location /status {
  55.                         stub_status on;
  56.                         access_log   off;
  57.                 }

  58.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  59.                         {
  60.                                 expires      30d;
  61.                         }

  62.                 location ~ .*\.(js|css)?$
  63.                         {
  64.                                 expires      12h;
  65.                         }

  66.                 log_format  access  '$remote_addr - $remote_user

  67. [$time_local] "$request" '
  68.              '$status $body_bytes_sent "$http_referer" '
  69.              '"$http_user_agent" $http_x_forwarded_for';
  70.                 access_log  /home/wwwroot/logs/access.log  access;
  71.         }
  72. include vhost/*.conf;
  73. }
复制代码
##################################################################

虚拟主机的 .conf
  1. [root@libo vhost]# cat www.lvyou.jp.conf
  2. server
  3.         {
  4.                 listen       80;
  5.                 server_name www.lvyou.jp;
  6.                 index index.html index.htm index.php default.html default.htm default.php;
  7.                 root  /home/wwwroot/www.lvyou.jp;

  8.                 include lvyou.jp.conf;
  9.                 location ~ .*\.(php|php5)?$
  10.                         {
  11.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  12.                                 fastcgi_index index.php;
  13.                                 include fcgi.conf;
  14.                         }

  15.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  16.                         {
  17.                                 expires      30d;
  18.                         }

  19.                 location ~ .*\.(js|css)?$
  20.                         {
  21.                                 expires      12h;
  22.                         }

  23.                 access_log off;
  24.         }
  25. [root@libo vhost]#
复制代码
##################################################
fcgi.conf的  这里试过两个 一个是军哥给的,一个是熊哥提供,但都不成

首先是按军哥的提示 改的 再本贴7楼

https://bbs.vpser.net/viewthread.php?tid=1534&page=1&fromuid=1710#pid2068


另一个是 按熊哥提供的

  1. #fastcgi_pass   127.0.0.1:9000;
  2. ##fastcgi_index  index.php;

  3. set $path_info "";
  4. set $real_script_name $fastcgi_script_name;
  5. if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
  6.         set $real_script_name $1;
  7.         set $path_info $2;

  8. }
  9. if ( $fastcgi_script_name ~ \..*\/.*php ) {
  10. return 403;
  11. }
  12. fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
  13. fastcgi_param SCRIPT_NAME $real_script_name;
  14. fastcgi_param PATH_INFO $path_info;
  15. ##

  16. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  17. fastcgi_param  SERVER_SOFTWARE    nginx;

  18. fastcgi_param  QUERY_STRING       $query_string;
  19. fastcgi_param  REQUEST_METHOD     $request_method;
  20. fastcgi_param  CONTENT_TYPE       $content_type;
  21. fastcgi_param  CONTENT_LENGTH     $content_length;

  22. #fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  23. #fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  24. fastcgi_param  REQUEST_URI        $request_uri;
  25. fastcgi_param  DOCUMENT_URI       $document_uri;
  26. fastcgi_param  DOCUMENT_ROOT      $document_root;
  27. fastcgi_param  SERVER_PROTOCOL    $server_protocol;

  28. fastcgi_param  REMOTE_ADDR        $remote_addr;
  29. fastcgi_param  REMOTE_PORT        $remote_port;
  30. fastcgi_param  SERVER_ADDR        $server_addr;
  31. fastcgi_param  SERVER_PORT        $server_port;
  32. fastcgi_param  SERVER_NAME        $server_name;

  33. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  34. fastcgi_param  REDIRECT_STATUS    200;
复制代码

[ 本帖最后由 孤独剑客 于 2010-8-13 14:21 编辑 ]

军哥运维代购:http://shop63846532.taobao.com/

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

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-8 07:38 , Processed in 0.028674 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表