Created
March 24, 2024 03:06
-
-
Save mauriballes/db736f7497fea230cb9dc94e3e70da1b to your computer and use it in GitHub Desktop.
Installation script for moodle usign Ubuntu 22.04
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
#!/bin/bash | |
apt-get update | |
apt-get install nginx mariadb-server -y | |
apt install software-properties-common ca-certificates lsb-release apt-transport-https -y | |
add-apt-repository ppa:ondrej/php -y | |
apt install php7.4 php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-soap php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip unzip git curl -y | |
sed -i 's,^memory_limit =.*$,memory_limit = 256M,' /etc/php/7.4/fpm/php.ini | |
sed -i 's,^;max_input_vars =.*$,max_input_vars = 6000,' /etc/php/7.4/fpm/php.ini | |
sed -i 's,^;cgi.fix_pathinfo=.*$,cgi.fix_pathinfo = 0,' /etc/php/7.4/fpm/php.ini | |
sed -i 's,^upload_max_filesize =.*$,upload_max_filesize = 100M,' /etc/php/7.4/fpm/php.ini | |
sed -i 's,^max_execution_time =.*$,max_execution_time = 360,' /etc/php/7.4/fpm/php.ini | |
sed -i 's,^;date.timezone =.*$,date.timezone = UTC,' /etc/php/7.4/fpm/php.ini | |
systemctl restart php7.4-fpm | |
cat >/tmp/query.sql <<'SQL_STATEMENTS' | |
DROP USER IF EXISTS 'moodle'@'localhost'; | |
DROP DATABASE IF EXISTS moodledb; | |
CREATE DATABASE moodledb; | |
CREATE USER 'moodle'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL ON moodledb.* TO 'moodle'@'localhost' WITH GRANT OPTION; | |
FLUSH PRIVILEGES; | |
SQL_STATEMENTS | |
mysql -Be "SOURCE /tmp/query.sql" | |
sed -i '/\[mysqld\]/a innodb_large_prefix = ON' /etc/mysql/mariadb.conf.d/50-server.cnf | |
sed -i '/\[mysqld\]/a innodb_file_per_table = 1' /etc/mysql/mariadb.conf.d/50-server.cnf | |
sed -i '/\[mysqld\]/a innodb_file_format = Barracuda' /etc/mysql/mariadb.conf.d/50-server.cnf | |
systemctl restart mariadb | |
cd /var/www/html | |
git clone -b MOODLE_400_STABLE git://git.moodle.org/moodle.git moodle | |
mkdir -p /var/www/html/moodledata | |
chown -R www-data:www-data /var/www/html/moodle | |
chmod -R 755 /var/www/html/* | |
chown www-data:www-data /var/www/html/moodledata | |
cat >/etc/nginx/conf.d/moodle.conf <<'NGINX' | |
server { | |
listen 80; | |
root /var/www/html/moodle; | |
index index.php index.html index.htm; | |
server_name moodle.example.com; | |
client_max_body_size 100M; | |
autoindex off; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
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; | |
} | |
} | |
NGINX | |
nginx -t | |
systemctl restart nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment