I am going to use use a Centos 7 minimal install virtual box machine. So the first step is to clone the VM with new mac address.
CentOS: 7.7
php: 7.3.16
mariadb: 10.1.41
nginx: 1.16.1
add "IP_address moodle.casa.int" to your /etc/hosts
hostnamectl set-hostname moodle01 --static
reboot
In order to connect through ssh from your local machine to your VM you need set port forwarding as follow:
ip addr show
In VB, you have to create a portforwarding as:
Name: ssh Protocol: TCP
Host IP: 127.0.0.1
Host Portl: 2222
Guest IP: 10.0.2.15 (the same showed in the previuos command)
GuestPort: 2222
Generate the key pairs
ssh-keygen -t ecdsa -f .ssh/id_moodle
ssh-copy-id -p 2222 -i .ssh/id_moodle [email protected]
add the following lines to your .ssh/config:
Host moodle
Hostname 127.0.0.1
IdentityFile ~/.ssh/id_moodle
Port 2222
User root
ForwardAgent yes
Now, you will be able to run ssh moodle
yum -y install epel-release
yum -y install https://$(rpm -E '%{?centos:centos}%{!?centos:rhel}%{rhel}').iuscommunity.org/ius-release.rpm
yum -y install yum-plugin-replace
yum update
yum -y install vim-enhanced tcpdump wget yum-utils
yum remove mariadb-libs
yum install mariadb101u.x86_64 mariadb101u-server.x86_64
/usr/bin/mysql_secure_installation
* Enter current password for root (enter for none): Just press the Enter button
* Set root password? [Y/n]: Y
* New password: your-root-password
* Re-enter new password: your-root-password
* Remove anonymous users? [Y/n]: Y
* Disallow root login remotely? [Y/n]: Y
* Remove test database and access to it? [Y/n]: Y
* Reload privilege tables now? [Y/n]: Y
mysql -uroot -p mysql
CREATE DATABASE moodle DEFAULT CHARACTER SET UTF8 COLLATE utf8_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'moodpass';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'moodpass' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT
yum -y install nginx
yum -y install mod_php73 php73-common php73-mbstring php73-xmlrpc php73-soap php73-gd php73-xml \
php73-cli php73-json php73-mysqlnd php73-intl php73-fpm php73-fpm-nginx
mkdir /var/run/php-fpm
sed -i 's/server 127.0.0.1:9000/\#server 127.0.0.1:9000/' /etc/nginx/conf.d/php-fpm.conf
sed -i '/#server/a server unix:/var/run/php-fpm/www.sock;' /etc/nginx/conf.d/php-fpm.conf
systemctl restart nginx
Edit /etc/php-fpm.d/www.conf and replace the following lines:
user =
group =
listen =
listen.owner =
listen.group =
listen.mode =
by
user = nginx
group = nginx
listen = /var/run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
server {
access_log /var/log/nginx/moodle.casa.int-access_log;
error_log /var/log/nginx/moodle.casa.int-error_log crit;
listen 80;
server_name moodle.casa.int;
location / {
root /var/www/html/moodle;
index index.php index.html index.htm;
# moodle rewrite rules
rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;
}
# php parsing
location ~ .php$ {
root /var/www/html/moodle;
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
EOF
wget -v https://download.moodle.org/download.php/stable38/moodle-3.8.2.tgz
tar xzvf moodle-3.8.2.tgz -C /var/www/html/
sudo mkdir /var/www/moodledata
sudo chown -R nginx:nginx /var/www/moodledata
sudo chmod -R 755 /var/www/moodledata
connect to http://moodle.casa.int
crontab -u apache -e
Populate the cron file with:
* * * * * /usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null