Run this command on screen every time you log in, so when you get cut off, you can just pick up from where you left off:
screen -dR primecut
Following the processes and commands below should enable you to run a fully functioning Moodle installation on a minimally endowed Ubuntu machine.
fallocate -l 1G /swapfile1G
mkswap /swapfile1G
swapon /swapfile1G
swapon -s
nano /etc/fstab
to add the ff entry:
/swapfile1G none swap sw 0 0
sudo add-apt-repository ppa:ondrej/php7.3
apt update && sudo apt upgrade
apt install -y mysql-client mysql-server php7.3 libapache2-mod-php7.3 php7.3-mysql php7.3-mysqli graphviz aspell ghostscript clamav php7.3-pspell php7.3-curl php7.3-gd php7.3-intl php7.3-xml php7.3-xmlrpc php7.3-ldap php7.3-zip php7.3-soap php7.3-mbstring apache2
apt install mysql
mysql_secure_installation
Set your root password, remove anonymous users, disallow root's remote login, remove test database, reload privilege tables now.
mysql -u root -p[rootpasswordhere]
CREATE DATABASE moodle;
CREATE user 'moodleadmin'@'localhost' IDENTIFIED BY 'Secur3P@zzwd';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleadmin@localhost IDENTIFIED BY 'Secur3P@zzwd';
FLUSH PRIVILEGES;
quit;
sudo chown www-data:www-data -R /var/www/html/moodle
sudo chmod 775 -R /var/www/html/moodle
sudo mkdir -p /var/moodledata
sudo chmod 775 -R /var/moodledata
sudo chown www-data:www-data -R /var/moodledata
cd /var/www/html/moodle/
sudo cp config-dist.php config.php
nano config.php
Set up your config.php
$CFG->dbtype = 'mysql';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'mysite.com' or IP
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodleadmin'; // your database username
$CFG->dbpass = 'Secur3P@zzwd'; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names
$CFG->wwwroot = 'http://<domain name>';
$CFG->dataroot = '/var/moodledata';
cd /etc/sites-available/
nano mymoodle.prime.edu.ph.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/moodle/
ServerName myrmoodle.prime.edu.ph
<Directory /var/www/html/moodle/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2enmod rewrite
sudo a2ensite mymoodle.prime.edu.ph.conf
systemctl restart apache2
You may also have to disable the default vhost. Check the actual file. It could be
sudo a2dissite 000-default.conf
systemctl restart apache2
http://[server-IP]/install.php
Web address: [ your IP address or domain name ]
Moodle directory: /var/www/html/moodle
Data Directory: /var/moodledata
Click next. Get to database section and fill out these fields:
Database host: localhost
Database name: moodle
Database user: moodleadmin
Database password: Secur3P@zzwd
Tables prefix: mdl_
Get to the section where you have to set up the site administrator. Under General, you see
Username:
New password:
First name:
Surname:
/var/moodledata
/var/www/html/moodle
[ db backup ]
mysqldump -h localhost -u root --password=mypassword -C -Q -e --create-options moodle > moodle-database.sql
mysql -u root -pmypassword moodle < moodle-database.sql
In case you don't have an email account that can be used to send out emails in bulk, you may also use the Moodle server itself as a send-only postfix mailer.
sudo apt install mailutils
If prompted for type of mail configuration, just choose Internet site. For the system mail name, it is important you key in your FQDN (fully qualified domain name), the one reflected on your rDNS, so something like
mymoodlesite.prime.edu.ph
Once done, you may configure your postfix:
nano /etc/postfix/main.cf
Replace the appropriate lines with these:
inet_interfaces = loopback-only
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, $mydomain
sudo systemctl restart postfix
Once done, you may test your mailer with this:
echo "Just testing the send-only postfix" | mail -s "Testing 1 2 3" <yourdestinationemailhere>
Note that the initial messages coming out of this server will be flagged as “spam”. If you want it to be “perfect” right from the get-go, you need to know more about TXT records, SPF, DKIM, Amavis. Otherwise, your mails will get better over time.
Every site needs encryption these days. So you may install an SSL Certificate on your site. This section requires that you have a proper rDNS entry on your machine and your DNS points to your machine's IP with an A/AAAA record.
sudo apt install snapd
sudo snap install --classic certbot
sudo certbot --apache
We recommend an autoredirect to the secure site. Once done, confirm by adding S to your address in the “http”. So something like httpS://mymoodlesite.prime.edu.ph