0

サブディレクトリで nginx を CakePHP と連携させるのに非常に苦労しています。

私は Apache しか知らず、何か新しいことを学びたいので、nginx を使用しています。私の目標は、サブディレクトリで CakePHP をホストすることです。

/etc/nginx/sites-available/default ファイルは次のようになります。

server {

listen 0.0.0.0:80;
root /var/www/;
index index.html index.php;

include /etc/nginx/include/php;
error_page 404 = /404.html;

location / {
    root index.html;
    index index.php index.html index.htm;
    autoindex on;
    try_files $uri $uri/ /index.php;
}

location /randodb {
    if (!-e $request_filename) {
        rewrite ^/randodb(.+)$ /randodb/app/webroot/$1 last;
        break;
    }
}

location /randodb/app/webroot {
    if (!-e $request_filename) {
        rewrite ^/randodb/app/webroot/(.+)$ /randodb/app/webroot/index.php?url=$1 last;
        break;
    }
  }
}

server {

listen 0.0.0.0:443;
root /var/www/;
index index.html index.php;

fastcgi_param HTTPS on;
include /etc/nginx/include/ssl;
include /etc/nginx/include/php;

error_page 404 = /404.html;


}

私が何をしても、/randodb フォルダー内のすべての要求は 301 リダイレクトを受け取ります。

それはいつも私をリダイレクトしますhttp://nginx-php-fastcgi/randodb/

この動作を確認したい場合: http://www.matgilbert.com/randodb

4

1 に答える 1

0

まず、必要なブロックはこれだけです

location ~ /randodb(.*) {
    root /var/www/randodb/app/webroot;
    try_files $1 $1/ /index.php?url=$1;
}

上記の/ブロックで、root index.html;これが何をすべきかを指定しましたが、これは間違っていると思います。ルートはディレクトリであるはずです。

このブロックについて

fastcgi_param HTTPS on;
include /etc/nginx/include/ssl;
include /etc/nginx/include/php;

PHPは動作していますか?fast-cgi や fpm とは違うものを使用していますか?

次にsslブロック、これが私のサーバー上の私のsslブロックです

server {
    listen 443 ssl;
    ssl_certificate /etc/ssl/name.crt;
    ssl_certificate_key /etc/ssl/name.key;
    server_name example.com
    location / {
        # the rest of my config
    }
}
于 2013-06-15T06:30:43.477 に答える