1. 程式人生 > 實用技巧 >PHPBB3 Both the database and the directory containing it must be writable -- 含解題過程

PHPBB3 Both the database and the directory containing it must be writable -- 含解題過程

解題:我用的是SQLite資料庫,原因是沒有填對資料庫路徑,
Database server name: /var/www/html/phpBB3/db

解題過程:

1.Google Both the database and the directory containing it must be writable
發現 https://fossies.org/linux/phpBB/language/en/install.php中有以下內容
'INST_ERR_DB_NO_WRITABLE' => 'Both the database and the directory containing it must be writable.',

2.在安裝包目錄查詢INST_ERR_DB_NO_WRITABLE

grep -ir "INST_ERR_DB_NO_WRITABLE" phpBB3/*
找到:/var/www/html/phpBB3/phpbb/install/helper/database.php

    // Check if SQLite database is writable
    if ($dbms_info['SCHEMA'] === 'sqlite'
        && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this
->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) { $errors[] = array( 'title' =>'INST_ERR_DB_NO_WRITABLE', ); }

就以為是填localhost,又以為是填localhost/phpBB3/db 都不對,雖然安裝成功,到後面點選ACP訪問管理後臺時報錯:

General Error
SQL ERROR [ sqlite3 ]
no such table: phpbb_config [
1] An sql error occurred while fetching this page. Please contact an administrator if this problem persists.

3.又Google no such table: phpbb_config 沒有找到答案.

4.再看database.php這段程式碼this->filesystem->is_writable($dbhost)
靈機一動,dbhost應該是本地的一個路徑,我在phpBB3裡新建了一個db目錄就可以了.
安裝時填寫Database server name為/var/www/html/phpBB3/db

5.大功告成:http://localhost/phpBB3/