nginx를 사용하는 하위 디렉터리의 CakePHP(규칙을 다시 작성하시겠습니까?)

nginx를 사용하는 하위 디렉터리의 CakePHP(규칙을 다시 작성하시겠습니까?)

나는 이것을 얼마 전에 작동시킬 수 있었지만 시작했던 cakephp 프로젝트로 돌아왔을 때 최근에 nginx에 적용한 변경 사항(또는 아마도 최근 업데이트)이 내 재작성 규칙을 위반한 것 같습니다.

현재 나는 다음을 가지고 있습니다:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        location /basic_cake/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/basic_cake/(.+)$ /basic_cake/index.php?url=$1 last;
              break;
            }
        }

        location /cake_test/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/cake_test/(.+)$ /cake_test/index.php?url=$1 last;
              break;
            }
        }

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

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

    }

    server {
        listen       8081;
        server_name  localhost;

        root /srv/http/html/xsp;

        location / {
            index  index.html index.htm index.aspx default.aspx;
        }

        location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

}

내가 가진 문제는 CSS와 이미지가 웹루트에서 로드되지 않는다는 것입니다. 대신 내가 방문하면http://localhost/basic_cake/css/cake.generic.css, 다음 내용을 알려주는 페이지가 나타납니다.

CakePHP: 빠르게 개발되는 PHP 프레임워크 누락된 컨트롤러

오류: CssController를 찾을 수 없습니다.

오류: 아래 파일에 CssController 클래스를 생성하세요: app/controllers/css_controller.php

주의 사항: 이 오류 메시지를 사용자 정의하려면 app/views/errors/missing_controller.ctp를 생성하세요. CakePHP: 신속한 개발 PHP 프레임워크

이 문제를 해결하는 방법에 대한 아이디어가 있는 사람이 있나요?

답변1

결국 해결 방법을 사용했습니다. Apache를 설치하고 Proxy_pass nginx 지시문을 사용하여 특정 폴더의 트래픽을 Apache로 푸시했습니다.

답변2

내 생각에 문제는 재작성 규칙이 다음과 같아야 한다는 것입니다.

location / {
    root /home/public_html/sub.example.com/cake/app/webroot;
    index index.php;

    if (-f $request_filename) {
        break;
    }
    if (!-f $request_filename) {
        rewrite ^/(.+)$ /index.php?url=$1 last;
        break;
    }
}

비슷한 문제가 있었는데 이것을 통해 해결되었습니다.cakephp 및 nginx 구성/재작성 규칙

관련 정보