Skip to content

CLI script to run a Docker based Apache/PHP web server targeted at - but not limited to - Moodle installations

Notifications You must be signed in to change notification settings

QMUL/moodlehost

Repository files navigation

MoodleHost

What is this?

MoodleHost provides a simple CLI command to run an Apache web server with all the trimmings ready to run a Moodle environment for development or testing. It is based on the Docker image moodlehq/moodle-php-apache and adds xdebug with sessionkey PHPSTORM.

ATTENTION: The resulting web server is by no means secure. Never use it for production environments!

Preliminaries

You need to have Docker installed to use MoodleHost.

Installation

To install MoodleHost on you need to run the install_moodlehost script as superuser (e.g. $ sudo ./install_moodlehost).

This will place the moodlehost into /usr/local/bin/moodlehost and the configuration file into /etc/moodlehost.conf.

During the installation you will be prompted to edit the moodlehost configuration file. The configiuration file allows to set default values for the installation like the port and PHP version used when using the moodlehost command without options. Please note: Values in moodlehost.conf still may be overridden by options when running the moodlehost command.

the moodlehost command

The basic CLI command is

$ moodlehost [<options>] start / stop / purge / status

The available options are:

-d <db_host_ip>: set the IP address of the database server (default = 127.0.0.1)
-f <path_to_filedir>: map an existing filedir repository into /var/www/moodledata/filedir
-h : a help page
-m <moodledata>: set path on host(!) to moodledata (default is $PWD/moodledata)
-n host: forcing docker to use the host network
-p <port>: set the port number used by Apache (default=80)
-v <php_version>: select the PHP version (default=7.2, allowed values: 7.2, 7.3, 7.4)
-w <webroot>: set the path to the webroot directory (default: $PWD)

Usage

To use moodlehost simply change into the directory you want to host. There you may issue '$ moodlehost start' to start a server with default values (as of /etc/moodlehost.conf).

Now point your browser to "http://localhost" to see the resulting web page.

Please note: The resulting Docker container will be named 'moodlehost-<port>' (e.g. 'moodlehost-80'). When using a different port value other than the default one you will need to use the same option to stop the server again or purge it's moodledata (see below).

Available commands are:

moodlehost <options> start: start moodlehost server

moodlehost <options> stop: stop given moodlehost server

moodlehost <options> purge: remove all moodledata but the filedir for the given moodlehost server

moodlehost status: return a status message for every moodlehost instance running

config.php.sample

To allow to run a Moodle instance on any allowed port the setting for $CFG->wwwroot needs to be amended as shown in theconfig.php.samplefile. You may copy and modify it according to your setup. In this case please note as the IP address of the database server is mapped to 'db_host' inside the Docker container you may always address the$CFG->dbhostwith this, as shown in the sample.


v.1.6 2022-02-04

About

CLI script to run a Docker based Apache/PHP web server targeted at - but not limited to - Moodle installations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published