Monday, January 14, 2019

How to turn on Moodle debug message on Dockers container?

Software Required
- docker-compose version 1.22.0
- macOS High Sierra
- docker version 18.06.1-ce
Moodle version 3.6.1

Problems
- During the process of configuring Moodle on my Docker container, encountered the error message "Error reading from database" when launching my Moodle portal. I can't launch the Moodle main login page.
- I can't proceed from there and have no clue on what is going on that blocked the system from launching.
- I need more details through the Moodle debug message

Steps
- Came across Moodle support side, it provided steps to turn on the Moodle debug message. However, it does not provide the configuration details on Dockers.
- I'm using docker-compose, hence, I added configuration below to my docker-compose.yml file
volumes: - ./phpconf/custom.php.ini:/usr/local/etc/php/conf.d/custom.php.ini
- I created "phpconf" folder in my docker-compose parent folder and place "custom.php.ini" file in the folder.
- Below are the content of the "custom.php.ini" file. 
display_startup_errors=On
log_errors=On
- Added configuration below in the Moodle config.php
ini_set ('display_errors', 'on');
ini_set ('log_errors', 'on');
ini_set ('display_startup_errors', 'on');
ini_set ('error_reporting', E_ALL);
$CFG->debug = 30719; // DEBUG_ALL, but that constant is not defined here

//The configuration must above this line
require_once(__DIR__ . '/lib/setup.php');
- Restart the docker-compose by running the command below
#docker-compose down
#docker-compose kill
#docker-compose up
- Refresh the Moodle page, error message "Table "sessions" does not exist" is displayed. Obviously, the DB dump that I used to restore the database in Dockers MySQL database is not complete. 
- In order to check the configuration has been taken effect in the php.ini file, add phpinfo() into config.php. Reload the page, you will be able to confirm the implementation has been taken effect.




No comments: