いつもお世話になっております。
標記の件について、これまでnginx上で稼働させていたcakePHP2を利用して作ったアプリはそのままで、
同じドメイン上でEC CUBE3の機能を追加したいと考えております。
現在、cakePHP2のアプリでは以下のようなURLでアクセスしております。
http://sample.com/controllers1/action1/
http://sample.com/controllers2/
更にEC CUBE3では以下のようなURLでアクセスするのが目標です。
EC CUBEのみサブドメインで管理する方法もありますが、
できれば同じドメイン上で実現したいと考えております。
ファイルの保存先は現在以下のようにしています。
/var/www/html/sample/ cakePHP2のアプリの保存先
/var/www/html/payment/ EC CUBE3の保存先
また、nginxの設定ファイルは以下のようになっています。
config
server { listen 80; listen 443 ssl; server_name sample.com; ssl_certificate /etc/nginx/certs/sample.com.combined.crt; ssl_certificate_key /etc/nginx/certs/sample.com.key; ssl_session_timeout 5m; index index.html index.htm index.php; set $root_path '/var/www/html/sample/app/webroot'; root $root_path; location / { if (!-e $request_filename) { rewrite ^(.+)$ /index.php?url=$1 last; break; } if ($request_uri ~* ".(gif|jpe?g|png|ico|swf|woff)$") { expires 30d; } } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name; fastcgi_param SERVER_NAME $host; } }
この設定ファイルに対して、location /payment
に対する設定を追加すればよいかと思いますが、
どのように記述すればEC CUBE3を動かせるようになるか、ご教授いただけると幸いです。
当方にて試してみた内容を以下に追記させていただきます。
1 nginxの設定ファイルを変更しない場合
1.1
http://sample.com/payment/
にアクセスすると、cakePHP2のアプリのデフォルトのURLにリダイレクトされます。
1.2
http://sample.com/payment/eccube_install.php
http://sample.com/payment/html/install.php
にアクセスすると、File not found.
と表示されます。
2 nginxの設定ファイルのset $root_path
の前に以下を追加した場合
Bash
location /payment { set $root_path '/var/www/html/payment/html'; try_files $uri $uri/ /index.php$uri; }
2.1
http://sample.com/payment/
にアクセスすると、cakePHP2のアプリのデフォルトのURLにリダイレクトされます。
2.2
http://sample.com/payment/eccube_install.php
http://sample.com/payment/html/install.php
にアクセスすると、File not found.
と表示されます。
※nginxのエラーログ追記
Bash
[error] 25420#25420: *2886487 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ***.***.***.***, server: sample.com, request: "GET /payment/eccube_install.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sample.com" [error] 25420#25420: *2886506 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ***.***.***.***, server: sample.com, request: "GET /payment/html/install.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sample.com"
3 nginxの設定ファイルのlocation /
の前に以下を追加した場合
Bash
location /payment { try_files $uri /index.php$is_args$args; } location ~ /payment/install/(.*).php/.+$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; try_files $uri $uri/ /install.php; } location ~ /payment/(.*).php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; try_files $uri =404; }
3.1
http://sample.com/payment/
にアクセスすると、cakePHP2のアプリのデフォルトのURLにリダイレクトされます。
3.2
http://sample.com/payment/eccube_install.php
http://sample.com/payment/html/install.php
にアクセスすると、404 Not Found
と表示されます。
なお、/payment
の箇所を^/payment
に変更しても同じでした。
なお、サーバ環境などは以下になります。
CentOS 6.7
nginx 1.10.0
php 7.0.6
mysql 14.14
cakePHP 2.8.5
それでは、よろしくお願いいたします。
まだ回答がついていません
会員登録して回答してみよう