gpt4 book ai didi

mysql - Nginx CodeIgniter 不工作

转载 作者:行者123 更新时间:2023-11-29 13:51:58 25 4
gpt4 key购买 nike

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

我的示例网址如下:

http://example.com/track/

这是重定向到:

http://example.com/track/index.php/sessions/login

但它返回 404 Not Found。

我的服务器配置如下:

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;
}
}

我的错误日志文件是这样的

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"

怎么了?我在谷歌中进行了搜索,但效果不佳。

最佳答案

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

编辑:
好的,有多种方法可以解决您的情况,但我将描述最接近您的情况

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

location /track {
try_files $uri $uri/ /track/index.php;
}

不确定路由是否需要将 $request_uri 附加到 index.php 中。我认为您应该配置 CodeIgniter 以了解此子文件夹

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

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

关于mysql - Nginx CodeIgniter 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16557247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com