いつもお世話になっております。
標記の件について、これまで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
1server { 2 listen 80; 3 listen 443 ssl; 4 server_name sample.com; 5 6 ssl_certificate /etc/nginx/certs/sample.com.combined.crt; 7 ssl_certificate_key /etc/nginx/certs/sample.com.key; 8 ssl_session_timeout 5m; 9 10 index index.html index.htm index.php; 11 set $root_path '/var/www/html/sample/app/webroot'; 12 root $root_path; 13 14 location / { 15 if (!-e $request_filename) { 16 rewrite ^(.+)$ /index.php?url=$1 last; 17 break; 18 } 19 20 if ($request_uri ~* ".(gif|jpe?g|png|ico|swf|woff)$") { 21 expires 30d; 22 } 23 } 24 25 location ~ .php$ { 26 fastcgi_pass 127.0.0.1:9000; 27 fastcgi_index index.php; 28 fastcgi_intercept_errors on; 29 include fastcgi_params; 30 fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name; 31 fastcgi_param SERVER_NAME $host; 32 } 33}
この設定ファイルに対して、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
1 location /payment { 2 set $root_path '/var/www/html/payment/html'; 3 try_files $uri $uri/ /index.php$uri; 4 }
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
1[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" 2 3[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
1 location /payment { 2 try_files $uri /index.php$is_args$args; 3 } 4 5 location ~ /payment/install/(.*).php/.+$ { 6 fastcgi_pass 127.0.0.1:9000; 7 fastcgi_index index.php; 8 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 9 fastcgi_param PATH_INFO $fastcgi_script_name; 10 include fastcgi_params; 11 try_files $uri $uri/ /install.php; 12 13 } 14 15 location ~ /payment/(.*).php { 16 fastcgi_pass 127.0.0.1:9000; 17 fastcgi_index index.php; 18 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 19 fastcgi_param PATH_INFO $fastcgi_script_name; 20 include fastcgi_params; 21 try_files $uri =404; 22 }
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
それでは、よろしくお願いいたします。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/05 06:57