LoginSignup
4
1

More than 5 years have passed since last update.

【cakephp】画面の表示がうまくいかない時

Posted at

ドキュメントルート

詳細は、こちら↓
http://book.cakephp.org/2.0/ja/deployment.html

通常は、
app/webroot/ をドキュメントルートに設定すべき。

URLリライティング

詳細は、こちら↓
http://book.cakephp.org/2.0/ja/installation/url-rewriting.html

◆ Apache と mod_rewrite (と.htaccess)

CakePHP は、mod_rewrite を使用するようになっている。

※mod_rewriteの詳細についての分かり易い記事
http://www.phpbook.jp/cakephp/install/index3.html

うまく画面が表示できなくて苦労することがあり、その為の解決策を幾つか下記に提示する。

httpd.confの確認

※これらのファイルは、ディストリビューションや Apache のバージョンによって異なる。

[確認1].htaccess のオーバーライドが許可されていること

[確認2]正確な DocumentRoot に対して AllowOverride が All に設定されていること
例を挙げると以下のようになる。

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
    Options FollowSymLinks
    AllowOverride All
#    Order deny,allow
#    Deny from all
</Directory>
Apache 2.4 以上の場合、 httpd.conf やバーチャルホストの設定を以下のように 更新する必要があります。

<Directory /var/www/>
     Options FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>

[確認3]mod_rewrite を正しく読み込んでいること。

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

↑デフォルトではコメントアウトされているので、コメントアウトを解除する。

[確認4]httpd.confは、設定を変更したら、必ずApacheを再起動すること。

[確認5].htaccess ファイルが実際に正しいディレクトリにあるか確認する。

[確認6]
CakePHP のコピーがサイトのダウンロードセクション、
または、Gitリポジトリからのものであることを確認する。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1