1

Apacheサーバーで「すぐに」動作するconcrete5サイトがあります。ただし、nginxで実行するのに多くの問題があります。

以下は、私が使用しているnginx構成です。

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ index.php;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            fastcgi_pass unix:/tmp/phpfpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            include fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
}

ホームページを取得できますが、内部ページに問題があります。内側のページに「アクセスが拒否されました」と表示されます。おそらく、書き換えが機能していない可能性があります。実際には、具体的なディスパッチャーを経由するのではなく、php ファイルを直接クエリして実行しようとしていると思います。

私はここで完全に迷っています。

よろしくお願いします。

4

1 に答える 1

3

構成を次のように変更しました。

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.php/$request_uri;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            set $script $uri;
            if ($uri ~ "^(.+\.php)(/.+)") {
                    set $script $1;
            }
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$script;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/tmp/phpfpm.sock;
    }

    location ~ /\.ht {
            deny  all;
    }
}

そして、ハングオーバーと彼がサーバーフォールトで提供したリンクのおかげで機能します。

何が間違っていたのかまだはっきりしていません。おそらくnginxの専門家が理解を助けることができます。

于 2012-06-27T16:39:39.697 に答える