【发布时间】:2017-01-14 03:35:58
【问题描述】:
我在 PHP-fpm 和 nginx (Ubuntu) 上安装了 CodeIgniter 3。以前我一直在 Windows 上使用 CodeIgniter,在 Windows 和 Apache 上配置它是小菜一碟。 现在我想在 nginx 上安装它,因为我想使用 nginx-push-stream-module,这在 apache 中是不可能的。
现在当我配置它时,它不起作用。
如果我输入 localhost/myexample.com 或 localhost/myexample.com/index.php 它会起作用(myexample.com 是该目录的名称)
但是当我尝试访问时
localhost/myexample.com/welcome
或
localhost/myexample.com/welcome/index
或
localhost/myexample.com/index.php/welcome
或
localhost/myexample.com/index.php/welcome/index
它在 4 种情况下都不起作用(有或没有 index.php)
我的根目录是/var/www/html/myexample.com
我尝试了来自不同博客文章等的所有在线可用的重写设置(包括以下设置)(因为我自己不习惯 nginx)
server {
server_name myexample.com;
root /var/www/html/myexample.com/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/myexample.com/index.php;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
编辑:我也尝试过 Nginx 官网提到的the method,但也不起作用。
【问题讨论】:
标签: php codeigniter nginx url-rewriting