2016-05-18 10 views
0

私はしばらくの間これと戦ってきましたが、まだそれを実行することはできません。私はcodeginiterのアプリケーションでopensuse tumbleweedで走っているnginxを手に入れました。opensuse(tumbleweed)+ nginx + codeigniter 404 issue

私はフロントページに問題はありませんが、コントローラを開く試みは404エラーで失敗します。

私がUbuntuで作業していたとき、ちょっとしたことで数分でこれを解決できましたが、何らかの理由でここで苦労しています。私はnginxのために私のデフォルトの設定ファイルを添付しています。過去にこれが働いていたので、実際に私がここに見ていないものがなければなりません。 opensuse上のnginxは本当にそのような痛みですか?

server { 
    listen  80; 
    server_name localhost; 
    root /usr/share/nginx/html/; 
    index index.php; 

    #charset koi8-r; 
    #access_log /var/log/nginx/log/host.access.log main; 

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

     ## Handling of CORS 
     if ($request_method = 'OPTIONS') { 
      add_header 'Access-Control-Allow-Origin' '*'; 
     # 
     # Om nom nom cookies 
     # 
      add_header 'Access-Control-Allow-Credentials' 'true'; 
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; 
     # 
     # Custom headers and headers various browsers *should* be OK with but aren't 
     # 
      add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; 
     # 
     # Tell client that this pre-flight info is valid for 20 days 
     # 
      add_header 'Access-Control-Max-Age' 1728000; 
      add_header 'Content-Type' 'text/plain charset=UTF-8'; 
      add_header 'Content-Length' 0; 
      return 204; 
     } 
     if ($request_method = 'POST') { 
      add_header 'Access-Control-Allow-Origin' '*'; 
      add_header 'Access-Control-Allow-Credentials' 'true'; 
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; 
      add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; 
     } 
     if ($request_method = 'GET') { 
      add_header 'Access-Control-Allow-Origin' '*'; 
      add_header 'Access-Control-Allow-Credentials' 'true'; 
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; 
      add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; 
     } 
    } 

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

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
    # 
    #location ~ \.php$ { 
    # proxy_pass http://127.0.0.1; 
    #} 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    location ~ \.php$ { 

     try_files $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     #fastcgi_ignore_client_abort off; 
    } 

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

答えて

0

私は結局問題を見つけて答えました。私はかなり完全に設定ファイルの内容を消去し、それらをnginxウェブサイト(here)で見つかったものに置き換えました。

configファイルにCORSを処理するための指示がなくても、フォント、スクリプトなどのすべての内容がローカルホストで不具合なく正常に動作していることが分かりました。誰かに使用されるであろう

server { 
    listen  80; 
    server_name localhost; 
    root /usr/share/nginx/html; 
    autoindex on; 
    index index.php; 

    location/{ 

      try_files $uri $uri/ /index.php; 

      location = /index.php { 

       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; 
       include  fastcgi_params; 
      } 
     } 

     location ~ \.php$ { 
      return 444; 
     } 

} 

希望;)