【问题标题】:ToroPHP nginx php5-fpm configurationToroPHP nginx php5-fpm 配置
【发布时间】:2013-05-30 19:19:03
【问题描述】:

配置 nginx php5-fpm(更改 domain.com)

server {
  listen 80 default;
  server_name domain.com;

  root /var/www/domain.com;
  access_log /var/log/nginx/domain.com.access_log;
  error_log /var/log/nginx/domain.com.error_log;
   index index.php;

   try_files $uri @rewrite;

  location @rewrite {
    rewrite ^/(.*)$ /index.php/$1;
  }   
  location ~ \.php {
   fastcgi_index index.php;
   fastcgi_pass 127.0.0.1:9000;
   include fastcgi_params;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  location ~ /\.ht {
    deny all;
  }
}

此代码不适用于根路径...

例子:

domain.com/parse/a/b --> 有效 domain.com/parse --> 有效

domain.com --> 不工作

【问题讨论】:

    标签: php .htaccess nginx


    【解决方案1】:

    以下内容应该可以帮助您解决问题:

    try_files $uri @rewrite 更改为try_files $uri $uri/ @rewrite

    rewrite ^/(.*)$ /index.php/$1; 更改为rewrite ^/(.*)$ /index.php?/$1 last; 以防止无限重写循环。

    如果这不能解决问题,请告诉我,我会进一步调查。

    【讨论】:

    • 旁注:你的最后一个 location 块可能与 nginx 无关,因为 nginx not 读取 htaccess。
    • 您的更改无法解析根 url ...示例仅访问 domain.com(没有任何路径)
    • 你能帮我解决这个问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-02
    • 2016-02-24
    • 2016-06-11
    • 2011-11-15
    • 2012-05-15
    • 2014-08-19
    • 1970-01-01
    相关资源
    最近更新 更多