Last active
January 26, 2023 00:16
-
-
Save duven87/1136cdd7b847d0f3aaf263ed7f53e489 to your computer and use it in GitHub Desktop.
Install Moodle with nginx + postgres + API Opencast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## INSTALL PACKAGES ## | |
apt install nginx php postgresql postgresql-contrib php-fpm php-curl php-gd php-xmlrpc php-intl php-xml php-zip php-mbstring php-soap php-common php-gmp php-cli unzip git curl php-pgsql certbot python3-certbot-nginx git locate fail2ban | |
## (OPTIONAL) ## | |
vim /etc/fail2ban/jail.conf | |
bantime = -1 | |
ignoreip = 192.168.3.0/24 (Internes network) | |
## SET DATE/TIME ## | |
sudo timedatectl set-timezone Europe/Berlin | |
timedatectl | |
updatedb | |
## POSTGRES CONFIGURATION ## | |
sudo -u postgres psql -c "SELECT version();" | |
service postgresql status | |
pg_ctlcluster 13 main start | |
su - postgres | |
psql | |
postgres=# CREATE DATABASE moodle; | |
postgres=# CREATE USER username WITH PASSWORD 'password'; | |
postgres=# GRANT ALL PRIVILEGES ON DATABASE moodle to username; | |
\q | |
##SECURITY: HIDDING NGINX VERSION ## | |
vim /etc/nginx/nginx.conf | |
http{ | |
... | |
+ server_tokens off; | |
... | |
## INSTALL MOODLE ## | |
cd /var/www/html | |
git clone -b MOODLE_400_STABLE git://git.moodle.org/moodle.git moodle | |
mkdir -p /var/www/html/moodledata | |
chown www-data:www-data /var/www/html/moodledata | |
chown -R www-data:www-data /var/www/html/moodle | |
## AUTH BASIC ## | |
apt install apache2-utils | |
sh -c "echo -n 'xxxxxx:' >> /etc/nginx/.htpasswd" | |
sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd" | |
cat /etc/nginx/.htpasswd | |
htpasswd -c /etc/nginx/.htpasswd xxxxxx | |
## | |
## OPTMIMIZING PHP ## | |
vim /etc/php/7.4/fpm/php.ini | |
memory_limit = 256M | |
cgi.fix_pathinfo = 0 | |
upload_max_filesize = 100M | |
max_execution_time = 360 | |
date.timezone = Europe/Berlin | |
max_input_vars = 7000 (min. 5000) | |
systemctl restart php7.4-fpm | |
## CONFIGURE NGINX ## | |
vim /etc/nginx/conf.d/moodle.conf | |
server { | |
root /var/www/html/moodle; | |
index index.php index.html index.htm; | |
server_name andres-moodle.kunde-ssystems.de; | |
client_max_body_size 100M; | |
autoindex off; | |
location / { | |
try_files $uri $uri/ =404; | |
## Auth Basic | |
auth_basic "Restricted Content"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
} | |
location /dataroot/ { | |
internal; | |
alias /var/www/html/moodledata/; | |
} | |
location ~ [^/].php(/|$) { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.4-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
## SSL CERTIFICATE WITH CERTBOT ## | |
certbot --nginx -d andres-moodle.kunde-ssystems.de | |
.....Then certbot create automatically redirections SSL: ...... | |
server { | |
root /var/www/html/moodle; | |
index index.php index.html index.htm; | |
server_name andres-moodle.kunde-ssystems.de; | |
client_max_body_size 100M; | |
autoindex off; | |
location / { | |
try_files $uri $uri/ =404; | |
auth_basic "Restricted Content"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
} | |
location /dataroot/ { | |
internal; | |
alias /var/www/html/moodledata/; | |
} | |
location ~ [^/].php(/|$) { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.4-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/andres-moodle.kunde-ssystems.de/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/andres-moodle.kunde-ssystems.de/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
if ($host = andres-moodle.kunde-ssystems.de) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name andres-moodle.kunde-ssystems.de; | |
return 404; # managed by Certbot | |
} | |
## CONFIGURE MOODLE ## | |
cp /var/www/html/moodle/config-dist.php /var/www/html/moodle/config.php | |
vim /var/www/html/moodle/config.php | |
<?php | |
unset($CFG); // Ignore this line | |
global $CFG; // This is necessary here for PHPUnit execution | |
$CFG = new stdClass(); | |
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mariadb', 'mysqli', 'auroramysql', 'sqlsrv' or 'oci' | |
$CFG->dblibrary = 'native'; // 'native' only at the moment | |
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP | |
$CFG->dbname = 'moodle'; // database name, eg moodle | |
$CFG->dbuser = 'username'; // your database username | |
$CFG->dbpass = 'password'; // your database password | |
... | |
$CFG->wwwroot = 'https://andres-moodle.kunde-ssystems.de'; | |
$CFG->dataroot = '/var/www/html/moodledata'; | |
service nginx restart | |
crontab -u www-data -e | |
* * * * * /usr/bin/php /var/www/html/moodle/admin/cli/cron.php | |
### FROM BROWSER: andres-moodle.kunde-ssystems.de | |
Language: English | |
Confirm Paths: | |
Data Directory --> /var/www/html/moodledata/ | |
database user: username | |
database password: password | |
... | |
#How to create Course | |
Site Administration -> add a new course (test1) | |
#Create new users: | |
Site Administration -> add a new user (teacher & student) | |
#Insert users to course: | |
My Courses -> test1 -> Participants -> Enroll users -> student / teacher --> assign role (student/teacher) | |
## PLUGINS OPENCAST ## | |
https://moodle.org/plugins/index.php (create Acoount) | |
Site Administration -> Plugins -> Install plugins from the moodle plugins directory | |
(Redirection) Select Plugin and install --> + --> site name: ssystems + site URL: https://andres-moodle.kunde-ssystems.de + Moodle:4 + add --> install now | |
###API OPENCAST - MOODLE ## | |
Go to our opencast instance: andres-opencast.kunde-ssystems.de | |
Create on opencast a user with roles: | |
Users --> Add user --> Username: ssystems , Pass: xxxxxx+ , ROLES: ROLE_API_* ROLE_API ROLE_SUDO | |
Groups --> Opencast Project External Applications --> Details --> Users --> Add ssystems | |
Go to Moodle instance: andres-moodle.kunde-ssystems.de | |
Site administration --> Users --> Add a new user --> Username: ssystems , Pass: xxxxxxxxx+ | |
Site administration --> Plugins --> Admin tools>Opencast API | |
Opencast API URL: andres-opencast.kunde-ssystems.de | |
Username of Opencast API user : ssystems | |
Password of Opencast API user: xxxxxxx+ | |
Connection Test Tool | |
Opencast API URL test successful. | |
Opencast API User Credentials test successful. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment