オンプレミス環境のIISで稼働している CakePHP アプリケーションをホスティング環境への移行します。
ディレクトリ構成の変更に伴い、 CakePHP 側の設定ファイルの修正が必要となります。
今回のホスティング環境(iSLE infinito)では .htaccess ファイルによる URL Rewrite 機能が利用できるため web.config によるURL書き換えの設定は必要ありません。
- ホスティング環境(iSLE infinito)で新しいドメインを追加します
- ファイルを転送します
- ドメインの追加作業で作成されたcakephp.in00.ms-isle.com フォルダに webrootフォルダの内容を転送します。
F:\apps\cake_1.2.5\apps\webroot ==> /wwwroot/cakephp.in00.ms-isle.com
- webroot 以外のフォルダを転送します。
F:\apps\cake_1.2.5\ ==> /wwwroot/cake_1.2.5/app
- ドメインの追加作業で作成されたcakephp.in00.ms-isle.com フォルダに webrootフォルダの内容を転送します。
- 転送後のホスティング環境のディレクトリ構成
- 設定ファイルの修正
- エラー対応 以下のエラー対応のためsession.phpとcore.php の一部を修正しました。
PHP Fatal error: Class ‘Security’ not found in D:\CustomerData?\webspaces\webspace_00118221\wwwroot\cake_1.2.5\cake\libs\session.php on line 157
- cake_1.2.5\cake\lib\session.php
//$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout')); $this->sessionTime = $this->time + ( 1 * Configure::read('Session.timeout'));- cake_1.2.5\app\config\core.php
Configure::write('Security.level', 'medium'); - 確認
- 以下のファイル、設定を確認します。
cakephp.in00.ms-isle.com/.hteccess<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> - また apps/tmp 以下のフォルダの作成および tmp 以下のフォルダの更新権限が必要です。
- 動作確認
- 以下のファイル、設定を確認します。
CakePHP のセットアップを参考にcake_1.2.5\app\webroot\index.phpファイルの内容を編集します。
if (!defined('ROOT')) {
define('ROOT','D:/CustomerData/webspaces/webspace_00118221'.DS.'wwwroot'.DS.'cake_1.2.5' );
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}
また、データベースの接続情報 cake_1.2.5\app\config\database.php をホスティング環境に合わせて修正します。
以上
関連記事
タグ: URL Rewrite






