CentOS Server - Moodle
- Moodle Checklist
- Prerequisite
- PHP Settings
- PHP Extensions
- MySQL Settings
- MySQL Database
- Folder Structure
- Virtual Host File
- SSL Certificate
- Installation
- Post Installation
Moodle Checklist
Moodle Checklist
Moodle Checklist
Moodle Checklist
| √ | To Do | |
Prerequisite |
||
| 1 | PHP settings | |
| 2 | PHP extensions | |
| 3 | MySQL settings | |
| 4 | MySQL database | |
| 5 | Folder structure | |
| 6 | Virtual host file | |
| 7 | SSL Certificate | |
Installation |
||
| 8 | Installing Moodle | |
| 9 | Adding plugins | |
Post Installation |
||
| 10 | Cron (automatic tasks) setup |
Prerequisite
Prerequisite
PHP Settings
Settings
- Check and set these settings in your php.ini
memory_limit
============
memory_limit = 128M
session.save_handler
====================
session.save_handler = files
file_uploads
============
file_uploads = On
session.auto_start
==================
session.auto_start = 0
post_max_size and upload_max_filesize
=====================================
post_max_size = 500M
upload_max_filesize = 500M
Restart Server
- Restart the web server after setting the above settings
systemctl restart httpd.service
Prerequisite
PHP Extensions
PHP Extensions
- Install the below list of PHP extensions with the command below (a lot of these extensions are installed by default when installing PHP). See Install PHP on how to install PHP.
-
-
- The iconv extension
- The mbstring extension
- The curl extension
- The openssl extension
- The tokenizer extension
- The xmlrpc extension
- The soap extension
- The ctype extension
- The zip extension
- The gd extension
- The simplexml extension
- The spl extension
- The pcre extension
- The dom extension
- The xml extension
- The intl extension
- The json extension
-
yum install php-mbstring curl php-xmlrpc php-soap php-gd php-xml php-intl php-json
Prerequisite
MySQL Settings
MySQL settings
Adding the configuration settings
- Open my.cnf file
vi /etc/my.cnf - Add the below config settings to the end of the file
[client]
default-character-set = utf8mb4
[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake
[mysql]
default-character-set = utf8mb4
Restart the MySQL daemon
- Restart the MySQL daemon after adding the configuration changes
systemctl restart mysqld
Prerequisite
MySQL Database
Setting up the MySQL Database
- Log into MySQL as root, providing the password at the prompt
mysql -u root -p - Create the database with the command below
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - Create a user/password combination with appropriate permissions for the database (replace moodle, moodleuser and yourpassword with an appropriate database name, username and password)
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword'; - Flush the privileges
flush privileges; - Exit the database
exit;
Prerequisite
Folder Structure
Creating a Moodle Folder Structure
Moodle Data Folder
Moodle Installation Folder
Prerequisite
Virtual Host File
Moodle Virtual Host File
- Create a virtual host configuration file for Moodle, like the example below (replacing subdomain.domain.com with an appropriate name). For more information on how to do this, see Apache Virtual Hosts
<VirtualHost subdomain.domain.com:80>
ServerName subdomain.domain.com
Redirect permanent / https://subdomain.domain.com
</VirtualHost>
<VirtualHost subdomain.domain.com:443>
ServerName subdomain.domain.com
DocumentRoot "/var/www/subdomain.domain.com"
<Directory "/var/www/subdomain.domain.com">
Options Indexes FollowSymLinks MultiViews
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
# Controls who can get stuff from this server file
Order allow,deny
Allow from all
</Directory>
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
Prerequisite
SSL Certificate
Obtaining a Certificate
- Run the command below (replacing example.com with the actual domain details)
certbot --apache -d example.com - Follow the prompts of the application
- At the option, "Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access," choose 1. Https redirection is configured in the domains conf file
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):1
For more information, see Let's Encrypt Certificates
Installation
Installation
Installing Moodle
Remember to configure DNS in Xneelo console if required
Downloading Moodle
- Go on this page and select the installation which suits your needs
- Navigate to /tmp folder and download the Moodle package with wget (replacing
https://link-to-moodle-package.comwith the appropriate download link for Moodle)cd /tmpwget https://link-to-moodle-package.com - Untar the downloaded package (replacing moodle-package.tar.gz with the appropriate name of the downloaded package)
tar -zxfv moodle-package.tar.gz - Move the uncompressed Moodle folder to /var/www (replacing moodle-folder with the name of the uncompressed folder)
mv moodle-folder /var/www - Change the owner of the folder and all the files
chown -R /var/www/moodle-folder
Moodle Web Installation
- Open your browser, you should get a page similar to this when you open the URL of the website. Select the language and click Next
- At the next screen change the Moodle data directory to the appropriate directory
- Select the appropriate database driver
- Enter the database details of the database that was created
- Now click and wait, after some seconds you should see the conditions, that you should accept
- Moodle will perform some system checks to test that everything is working fine
- Click Continue and other checks will come up....
- Click continue fill the data of admin user (Name, First, user password..)
- Finally you will land on the Administrator page
Installation
Adding plugins
Installing Plugins
Post Installation
Post Installation
Cron (automatic tasks) setup
Setting Moodle up for run tasks automatically
- Login to server as root
- Open crontab
crontab -e - Add the below line to crontab (replacing moodlefolder with the actual Moodle folder)
*/5 * * * * /usr/bin/php /var/www/moodlefolder/admin/cli/cron.php >/dev/null
The above example will run the command every 5 min