2

NGINX で実行されるストック CI アプリケーションがあります。書き換えなし(16時間試したけど動かなかった。500か404か403か入力ファイル指定なし)、php-fpmにphpファイルを渡す。

available-sites の下にあるデフォルトのファイルは次のとおりです (Ubuntu 12.04、CentOS ですべてを試しましたが、何も機能しませんでした)。

server {

        listen   80;    

        root /usr/share/nginx/www/;
        index index.php index.html index.htm;
        server_name fish-in-a-bowl.net;

        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www/cloud;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

        }
}

そしてconfig.php

$config['base_url'] = 'http://fish-in-a-bowl.net/zz/';

$config['index_page'] = 'index.php';

//$config['index_page'] = '';

//$config['uri_protocol']   = 'PATH_INFO';
//$config['uri_protocol']   = 'QUERY_STRING';
//$config['uri_protocol']   = 'REQUEST_URI';
//$config['uri_protocol']   = 'DOCUMENT_URI';
//$config['uri_protocol']   = 'ORIG_PATH_INFO';

$config['uri_protocol'] = 'AUTO';

利用可能なすべてのオプションを試しましたが、どれも機能しませんでした。このノードは Digital Ocean にあり、Apache で CI をセットアップするためのチュートリアルがありますが、NGINX はありません。

デフォルトのコントローラーは機能しますが、http://fish-in-a-bowl.net/zz/index.php/welcome経由でアクセスすると、No input file specified.

ヘルプ?これはとても奇妙です。

スクリーンショット >

ここに画像の説明を入力

4

6 に答える 6

1

nginx設定でこれを試してください

# enforce NO www
if ($host ~* ^www\.(.*))
{
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

# canonicalize codeigniter url end points
# if your default controller is something other than "welcome" you should change the following
if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
{
    rewrite ^(.*)$ / permanent;
}

# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
    rewrite ^/(.*)/index/?$ /$1 permanent;
}

# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
    rewrite ^/(.+)/$ /$1 permanent;
}

# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/system)
{
    rewrite ^/(.*)$ /index.php?/$1 last;
    break;
}

# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
    rewrite ^/(.*)$ /index.php?/$1 last;
    break;
}
于 2014-04-02T06:09:13.200 に答える
0

CI の新しいロケーション ブロックを追加するだけ

location ~ /zz(?<myuri>.*) {
    root /path/to/root/zz;
    try_files $myuri $myuri/ /index.php$myuri$is_args$query_string;
}

これですべてが完了し、テストして、どうなるか教えてください。

于 2013-08-02T04:12:40.970 に答える
0

次のことを試してみてください。私にとっては夢のようです。試す前に fastcgi_pass を変更し、現在の構成をバックアップすることを忘れないでください。

server
{
    listen   Server IP:80;
    server_name domain.name;

    access_log /var/log/nginx/access.log;

    root /path/to/www;

    index index.php index.html index.htm;

    # enforce www (exclude certain subdomains)
#   if ($host !~* ^(www|subdomain))
#   {
#       rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
#   }

    # enforce NO www
    if ($host ~* ^www\.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # canonicalize codeigniter url end points
    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # removes access to "system" folder, also allows a "System.php" controller
    if ($request_uri ~* ^/system)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # catch all
    error_page 404 /index.php;

    # use fastcgi for all php files
    location ~ \.php$
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /path/to/www/$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
}
于 2013-08-01T21:48:33.313 に答える
0
location /atri/ {
alias  /var/www/html/atri/;
try_files $uri $uri/ /atri/index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index   index.php;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    include /etc/nginx/fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME $request_filename;
}

}

于 2017-05-22T10:14:12.763 に答える