CakePHP3
PHP7.1
レンタルサーバ:さくらインターネット
プラン:スタンダード
マルチドメインを使用:/mydoc
ドキュメントルートをWWWに設置
intlはプラグインを設置して回避
パーミッションは.htaccessとindex.phpは755
症状:
おそらく.htaccessの記述が違うためマルチドメインのアドレスにアクセスしても、ページが表示されない
(HTTP ERROR 500)
サーバーエラーログ:
script not found or unable to stat: /home/xxx/www/index.php
File does not exist: /home/xxx/www/cake3
Directory index forbidden by Options directive: /home/xxx/www/
/home/xxx/
|-cake3-|
| |-srcフォルダなど
| |-htaccess
| |-index.php
|
|
|
|-www/mydoc/-|
| |-cssフォルダなど
| |-htaccess
| |-index.php
(図がずれているかも)
おそらく一般的な配置だと思います。
/home/xxx/cake3/.htaccess
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /cake3 RewriteRule ^$ ../www/mydoc/ [L] RewriteRule (.*) ../www/mydoc/$1 [L] </IfModule>/home/xxx/cake3/index.php
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
/home/xxx/www/mydoc/.htaccess
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>/home/xxx/www/mydoc/index.php
if (php_sapi_name() === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(FILE);
$url = parse_url(urldecode($_SERVER['REQUEST_URI'])); $file = __DIR__ . $url['path']; if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) { return false; }
}
require '/home/xxx/cake3/vendor/autoload.php';
use App\Application;
use Cake\Http\Server;
// Bind your application to the server.
$server = new Server(new Application('/home/xxx/cake3/config'));
// Run the request/response through the application
// and emit the response.
$server->emit($server->run());
ネット上の情報をかなり検索してみましたがダメでした。
cake2とフォルダ構成が違うため.htaccessで完全に止まっています。
どなたか.htaccessについて教えてもらえないでしょうか。
些細なことでもいいのでアドバイスよろしくおねがいします。
補足:
同じさくらインターネット・スタンダードプラン(マルチドメインを使用)に設置しているCakePHP2の.htaccessです。
PHPのバージョンなどは違いますが、それ以外は基本的には同じ環境です。
Cake2と3では、フォルダ構成が違うので3カ所に配置しています。
こちらは問題なく動作しています。
/home/xxx/cake2/app/.htaccess
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /cake2/app RewriteRule ^$ /www/mydoc/ [L] RewriteRule (.*) /www/mydoc/$1 [L] </IfModule>/home/xxx/cake2/.htaccess
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /cake2/app RewriteRule ^$ /www/mydoc/ [L] RewriteRule (.*) /www/mydoc/$1 [L] </IfModule>/home/xxx/www/mydoc/.htaccess
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule>追記:
https://moshimore.jp/knowledge/2016/08/09/sakura_server_cakephp3/
このページに書いてある通りに実行したら、webrootをマルチドメインに配置した状態でちゃんとcakephp3のトップページが表示されました。
intlもインストール
ただし、phpは5.6に変更
原因は不明ですが、上記のテストフォルダにプログラムを移植してローカルと同じように表示されました。
一応解決・・・??
とりあえずローカルで作ったcakephp3をzipファイルで上げて、サーバー上で展開すると思わぬ壁にぶち当たる可能性があります。
cakephp2のときは上手くいったんだけど・・・。
もし何が悪かったのかわかる方がいたら教えてほしいです。

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。