Moodle install

Table of Contents

How to install and setup Moodle locally

Moodle is an open source learning management system.

I want to install it to learn the working of it.

Moodle

Following this tutorial on my system.

Step-by-step Installation Guide for Ubuntu

Here I’ll try to follow the guide and add all the errors I encountered. Maybe it’ll help you.

About my system, I am using PopOS with Toolbox.

You can refer my previous post about [Podman](## TODO) there I have mentioned abput how to use toolbox.

Step 1. First lets create a toolbox:

$ toolbox create -i docker.io/akdev1l/ubuntu-toolbox:22.04 moodle_learning

Created container: moodle_learning
Enter with: toolbox enter moodle_learning

Don’t forget to update and upgrade the newly created toolbox

$ sudo apt update
$ sudo apt upgrade

Step 2. Install Apache/MySQL/PHP

Error

How to Fix ‘add-apt-repository command not found’ on Ubuntu & Debian

Followed this site for solution

Add repository:

sudo add-apt-repository ppa:ondrej/php 
sudo apt-get update

Install the packages:

sudo apt install apache2 mysql-client mysql-server php7.4 libapache2-mod-php

Run to secure:

sudo mysql_secure_installation
Enter password for user root: moodlesql

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Error

Error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

Check if service is started:

sudo service mysql start

Error

Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server.

Solution from Digital Ocean

Password is set to : moodlesql

Setting up apache2

Error after

sudo service apache2 start

Starting Apache httpd web server apache2
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80

(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down

AH00015: Unable to open logs

Action ‘start’ failed.

The Apache error log may have more information.

Solution:

cd /etc/apache2/
vim ports.conf

// Add Listen 8080

Error

sudo service apache2 start

Starting Apache httpd web server apache2 Segmentation fault (core dumped) Action ‘start’ failed. The Apache error log may have more information.

Solution:

There might 2 versions for PHP enabled so disable one of it by

 sudo a2dismod php<YourVersion>

Service:

$  sudo service <serviceName> start/stop/restart/status

$ sudo service apache2 start

Step 3. Download Moodle

sudo git clone git://git.moodle.org/moodle.git

Step 4: Copy local repository to /var/www/html/

sudo cp -R /opt/moodle /var/www/html/
sudo mkdir /var/moodledata
sudo chown -R www-data /var/moodledata
sudo chmod -R 777 /var/moodledata
sudo chmod -R 0755 /var/www/html/moodle

Step 5. Setup the MySql server:

First we need to change the default storage engine to innodb and change the default file format to Barracuda, this is a new setting compared to previous versions. You also need to set innodb_file_per_table in order for Barracuda to work properly.

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

Scroll down to the [mysqld] section and under Basic Settings add the following

default_storage_engine = innodb
innodb_file_per_table = 1
#innodb_file_format = Barracuda

Error

Can’t restart the server after setting

innodb_file_format = Barracuda

under file mysqld.cnf

Solution:

Maybe don’t specify it beacause file format is Barracuda by default.

After editing the file restart the mysqlserver

sudo service mysql restart

Create table in database now:

mysql>
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> create user 'atulyalearning'@'localhost' IDENTIFIED BY 'moodleatul';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'atulyalearning'@'localhost';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'atulyalearning'@'localhost' WITH GRANT OPTION;

Step 6. Complete Setup

Open the and “localhost:8080/moodle”

Follow the prompts:

Change the path for moodledata

/var/moodledata

Database Type

Choose: mysqli

Database Settings

Host server: localhost

Database: moodle

User: moodledude (the user you created when setting up the database)

Password: passwordformoodledude (the password for the user you created)

Tables Prefix: mdl_

Error

database driver problem detected

The site administrator should verify server configuration

PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP.

Solution:

  1. Delete the user and database created and install phpMyAdmin
mysql> DROP database moodle;


mysql> select user, host from mysql.user;
//view all the users

mysql> drop user atulyalearning@localhost;

Installing phpMyAdmin:

Tutorial

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

MySQL application password for phpmyadmin: moodlesqlphp


Error

phpmyadmin-mysqli-real-connect-hy000-2002-permission-denied-connection-f

Solution:

In File /etc/phpmyadmin/config-db.php

change

$dbserver=‘localhost’;

to

$dbserver=‘127.0.0.1’;

Restart Apache2


Error

Warning: mysqli::__construct(): (HY000/2002): Permission denied in /var/www/html/moodle/lib/dml/mysqli_native_moodle_database.php on line 85

Tags :