-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.moodle.almalinux.sh
69 lines (51 loc) · 2.03 KB
/
install.moodle.almalinux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Update system packages
sudo dnf update -y
# Install Nginx, MariaDB, PHP, and dependencies
sudo dnf install -y nginx mariadb-server mariadb-client php php-fpm php-gd php-mbstring php-xml php-curl php-zip unzip
# Start and enable MariaDB and PHP-FPM services
sudo systemctl start mariadb nginx php-fpm
sudo systemctl enable mariadb nginx php-fpm
# Secure MariaDB installation
sudo mysql_secure_installation
# Create a database for Moodle
mysql -u root -p <<EOF
CREATE DATABASE moodle;
EOF
# Create a user for Moodle and grant permissions
mysql -u root -p <<EOF
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'YourMoodlePassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EOF
# Download the latest Moodle codebase
sudo su - nobody -s /bin/bash -c 'wget https://download.moodle.org/latest.tar.gz'
# Extract the codebase
sudo tar -xvf latest.tar.gz
# Move the extracted directory to the document root for Nginx
sudo mv moodle /var/www/html/
# Set ownership and permissions for the Moodle directory
sudo chown -R apache:apache /var/www/html/moodle
# Configure Nginx for Moodle
sudo nano /etc/nginx/conf.d/moodle.conf
# Add the following configuration, replacing 'your_domain' with your actual domain name:
server {
listen 80;
server_name your_domain;
location / {
root /var/www/html/moodle;
index index.php index.html index.htm;
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
try_files $uri /index.php?$query_string;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
}
# Restart Nginx to apply configuration changes
sudo systemctl restart nginx
# Open a web browser and navigate to http://your_domain to complete the Moodle installation process.
echo "Moodle installation complete! Visit http://your_domain to finalize the setup using the database details created earlier."