CAKEPHPのDatabase Error
環境
ubuntu 16.04
PHP 7.0.22
CAKEPHP 3.5.6
mysql 5.7.20
Apache/2.4.18
現状
Error: SQLSTATE[HY000] [14] unable to open database file
まぁなんかDatabase Errorのエラーがいっぱい出てた
一応mysqlのユーザ名とパスワードはconfig/app.php
で設定済みなんだけどなぁ・・・。
因みにconfig/app.phpはこんな感じ
'Datasources' => [ 'default' => [ 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Database\Driver\Mysql', 'persistent' => false, 'host' => 'localhost', /** * CakePHP will use the default DB port based on the driver selected * MySQL on MAMP uses port 8889, MAMP users will want to uncomment * the following line and set the port accordingly */ //'port' => 'non_standard_port_number', 'username' => '[ユーザー名]', 'password' => '[パスワード]', 'database' => '[データベース名]', 'encoding' => 'utf8', 'timezone' => 'UTC', 'flags' => [], 'cacheMetadata' => true, 'log' => false,
ということで調査
とりあえずphp index.php
をたたいてエラーを見てみる
Security.saltを初期値から変更(事象とは関係ない)
Notice Error: Please change the value of 'Security.salt' in ROOT/config/app.php ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Security.saltが初期文字列だから変えてねって言われてた。ごめんなさい許してください変えます。
config/app.php
'Security' => [ 'salt' => env('SECURITY_SALT', '__SALT__'), ],
'__SALT__'
を適当な文字列に変えてあげるとこのエラーは消える
本題
エラーを下からたどっていくとこんなエラーが
/var/www/html/comporser/CAKEPHPTEST/vendor/cakephp/cakephp/src/ORM/TableRegistry.php
'DebugKit.Requests' [ 'alias' => 'Requests', 'className' => 'DebugKit\Model\Table\RequestsTable', 'connection' => object(Cake\Database\Connection) { 'config' => [ 'database' => '*****', 'driver' => 'Cake\Database\Driver\Sqlite', 'encoding' => 'utf8', 'cacheMetadata' => true, 'quoteIdentifiers' => false, 'name' => 'debug_kit' ], 'driver' => object(Cake\Database\Driver\Sqlite) {}, 'transactionLevel' => (int) 0, 'transactionStarted' => false, 'useSavePoints' => false, 'logQueries' => false, 'logger' => null }, 'registryAlias' => 'DebugKit.Requests' ]
なんか見てるDriverが怪しい・・・
公式 をみるとデフォルトで入ってるっぽい・・・ 「composer.phar」を一度updateする。
$composer.phar update Could not open input file: composer.phar
エラーが・・・
調べてみると「composer.phar」の場所は「which composer」でわかるらしいので見る
$ which composer /usr/bin/composer
updateをかけてみる
/usr/bin/composer update
一度アプリケーションを見る
とりあえずできたっぽいけど・・・こんな・・・・・簡素でしたかね・・・・
と思って調べてたら .htaccessを有効にする設定を記述をすればいいっぽいので編集
sudo vim /etc/apache2/apache2.conf
<Directory /var/www/html/[作ったアプリケーション名]> Options MultiViews FollowSymLinks AllowOverride All Allow from all </Directory>
設定してから再起
sudo /etc/init.d/apache2 restart
見たことある画面になった