Mysql Nginx编码点火器不工作

Mysql Nginx编码点火器不工作,mysql,codeigniter,configuration,nginx,php,Mysql,Codeigniter,Configuration,Nginx,Php,我是nginx的新手。我正在将我的服务器从apache转移到nginx,但是我在CodeIgniter核心PHP站点上的许多项目工作得很好,但是CodeIgniter不工作 我的示例url如下所示: http://example.com/track/ server { listen 80; server_name 192.168.0.80; location / { root /usr/share/nginx/html;

我是nginx的新手。我正在将我的服务器从apache转移到nginx,但是我在CodeIgniter核心PHP站点上的许多项目工作得很好,但是CodeIgniter不工作

我的示例url如下所示:

http://example.com/track/
server {
    listen       80;
    server_name  192.168.0.80;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }



    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
       deny  all;
    }
}
fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
这是重定向到:

http://example.com/track/index.php/sessions/login
但它返回404未找到

我的服务器配置如下:

http://example.com/track/
server {
    listen       80;
    server_name  192.168.0.80;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }



    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
       deny  all;
    }
}
fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
我的错误日志文件如下

2013/05/15 10:21:37 [error] 2474#0: *3 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:21:37 [error] 2474#0: *1 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/html/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.0.11, server: 192.168.0.80, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.0.80"
2013/05/15 10:22:05 [error] 2474#0: *1 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:26:46 [error] 2474#0: *5 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:28:33 [error] 2474#0: *7 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:29:59 [error] 2497#0: *1 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"

怎么了?我在谷歌上做了一个搜索,但没有很好地工作。

查看此链接,应该可以解决您的重写问题。
如果您还有其他问题,可以提问。

编辑:
好的,有几种方法可以解决您的问题,但我将介绍最接近您的问题

如果您要在与nginx conf相同的文件中进行编辑,就像我认为您现在所做的那样,那么请尝试添加此文件

location /track {
    try_files $uri $uri/ /track/index.php; 
}
不确定路由是否需要将
$request\u uri
附加到
index.php
中。 我认为您应该配置CodeIgniter以了解这个子文件夹

$config['base_url'] = "192.168.0.80/track"

这并不是最干净的配置方式,我更喜欢在
/etc/hosts
中添加域名,并在nginx中创建一个新的独立服务器。

我今天早些时候遇到了类似的问题:代码点火器URI路由要求定义请求URI和脚本名称变量。许多Nginx/PHP-FPM指南没有定义SCRIPT_NAME变量,因此最终会导致路由失败。您需要添加一行,如下所示:

http://example.com/track/
server {
    listen       80;
    server_name  192.168.0.80;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }



    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
       deny  all;
    }
}
fastcgi_param  SCRIPT_NAME $fastcgi_script_name;

然后您可以在config.php文件中使用REQUEST\u URI,路由应该可以工作。

将这两行替换为
fastcgi\u pass unix:/var/run/php5-fpm.sock
包括fastcgi_参数
当我调用这个URL重定向到&my core PHP项目不工作时,事情变得更糟了。很明显,您在端口而不是套接字上使用了
fastcgi
,因此您可以使用
fastcgi\u pass 127.0.0.1:9000
删除带有
fastcgi.conf
的行,并将其替换为
包含fastcgi_参数,我正在重写我的答案,以获得更详细的版本OK,所以有几个快速问题,这是本地服务器吗?这个codeIgniter项目是否在您的服务器根目录的子文件夹中运行?因为如果是这样,它会有一些变化,这是本地服务器。我正在子文件夹上运行centos for&codigniter