-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.mahara.lamp.sh
80 lines (63 loc) · 2.3 KB
/
install.mahara.lamp.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
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Ensuring the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Step 1: Update your system
echo "Updating system..."
yum update -y
# Step 2: Install Apache
echo "Installing Apache..."
yum install -y httpd
# Start and enable Apache to run on boot
systemctl start httpd
systemctl enable httpd
# Step 3: Install MariaDB
echo "Installing MariaDB..."
yum install -y mariadb-server
# Start and enable MariaDB
systemctl start mariadb
systemctl enable mariadb
# Secure MariaDB installation
mysql_secure_installation
# Step 4: Install PHP and required extensions
echo "Installing PHP and extensions..."
yum install -y epel-release
yum install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
yum module reset php
yum module enable php:remi-7.4
yum install -y php php-mysqlnd php-curl php-gd php-xml php-mbstring php-json php-zip
# Restart Apache to load the new PHP module
systemctl restart httpd
# Step 5: Create a database for Mahara
echo "Creating MariaDB database and user for Mahara..."
mysql -u root -p -e "CREATE DATABASE mahara_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p -e "GRANT ALL ON mahara_db.* TO 'mahara_user'@'localhost' IDENTIFIED BY 'secure_password';"
mysql -u root -p -e "FLUSH PRIVILEGES;"
# Step 6: Download and install Mahara
echo "Downloading Mahara..."
wget https://launchpad.net/mahara/21.04/21.04.2/+download/mahara-21.04.2.zip
unzip mahara-21.04.2.zip -d /var/www/html/
# Give proper permissions
chown -R apache:apache /var/www/html/mahara-21.04.2
chmod -R 755 /var/www/html/mahara-21.04.2
# Step 7: Configure Apache for Mahara
echo "Configuring Apache for Mahara..."
cat > /etc/httpd/conf.d/mahara.conf << EOF
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/var/www/html/mahara-21.04.2/htdocs"
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<Directory "/var/www/html/mahara-21.04.2/htdocs">
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/mahara_error.log
CustomLog /var/log/httpd/mahara_requests.log combined
</VirtualHost>
EOF
# Restart Apache to apply changes
systemctl restart httpd
echo "Mahara installation is complete. Please navigate to your domain to complete the setup through the web interface."