From 9a02018d85b8e1048ca3546c1db8bac95ae21945 Mon Sep 17 00:00:00 2001 From: Robert Spencer Date: Thu, 9 May 2024 19:35:49 +0200 Subject: [PATCH] WIP: Fix ubuntu.sh --- install/ubuntu.sh | 114 +++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/install/ubuntu.sh b/install/ubuntu.sh index e2f0dfc0a8..9ecef71740 100644 --- a/install/ubuntu.sh +++ b/install/ubuntu.sh @@ -1,47 +1,75 @@ -sudo apt update ; sudo apt upgrade -y -sudo apt install unzip wget git -y -sudo apt install apache2 -y -sudo apt install mysql-server -y - -sudo apt install php libapache2-mod-php -y -sudo apt install php-curl php-cli php-dev php-gd php-intl php-json php-mysql php-bcmath php-mbstring php-soap php-xml php-zip -y -cd /tmp -git clone https://github.com/ChurchCRM/CRM.git -cd /var/www -sudo rm -rf html -sudo cp -r /tmp/CRM/src /var/www/html -sudo rm -rf /tmp/CRM -cd /var/www/html/ -sudo find . -exec chown www-data:www-data "{}" \; -sudo find . -type f -exec chmod 644 "{}" \; -sudo find . -type d -exec chmod 755 "{}" \; -sudo chmod 755 /var/www/html/Include -sudo chmod 755 /var/www/html/Images -sudo a2enmod rewrite -sudo systemctl restart apache2 - -## Creating the database ##Please change the variables -## Please make sure to secure your Mysql server -BIN_MYSQL=$(which mysql) -DB_HOST='localhost' -DB_NAME='' ## Enter the database name -DB_USER='' ## enter the database username -DB_PASS='' ## enter the password -sudo mysql -e "CREATE DATABASE ${DB_NAME} /*\!40100 DEFAULT CHARACTER SET utf8 */;" -sudo mysql -e "CREATE USER ${DB_USER}@localhost IDENTIFIED BY '${DB_PASS}';" -sudo mysql -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost';" -sudo mysql -e "FLUSH PRIVILEGES;" - -# Define the domain name of the server -DOMAIN="" -# Set-up the required BookStack apache config +#!/usr/bin/env sh + +## Please change and enable these variables: +#DataBaseName='' +#DataBaseUserName='' +#DataBasePassword='' + +# Error on unset variable or parameter and exit +set -u + +sudo apt update +sudo apt upgrade -y +sudo apt install -y \ + apache2 \ + libapache2-mod-php8.2 \ + mariadb-client \ + mariadb-server \ + php8.2 \ + php8.2-bcmath \ + php8.2-cli \ + php8.2-curl \ + php8.2-dev \ + php8.2-gd \ + php8.2-intl \ + php8.2-mbstring \ + php8.2-mysql \ + php8.2-soap \ + php8.2-xml \ + php8.2-zip \ + unzip \ + wget + +cd /var/www/html || exit +Version=$(curl -Is https://github.com/ChurchCRM/CRM/releases/latest | awk -F\/ '/^location:/ {print $NF}') +sudo wget "https://github.com/ChurchCRM/CRM/releases/download/$Version/ChurchCRM-$Version.zip" +sudo unzip "ChurchCRM-$Version.zip" && sudo rm "ChurchCRM-$Version.zip" +sudo chown -R www-data:www-data churchcrm + +sudo systemctl restart apache2.service +sudo systemctl enable apache2.service +sudo systemctl restart mariadb.service +sudo systemctl enable mariadb.service + +## Creating the database +which mariadb || exit +sudo mariadb -uroot -p -e "CREATE DATABASE ${DataBaseName} /*\!40100 DEFAULT CHARACTER SET utf8 */; +CREATE USER ${DataBaseUserName}@'localhost' IDENTIFIED BY '${DataBasePassword}'; +GRANT ALL ON ${DataBaseName}.* TO '${DataBaseUserName}'@'localhost' WITH GRANT OPTION; +FLUSH PRIVILEGES;" + +echo "Please make sure to secure your database server:" +echo " sudo mysql_secure_installation" + +# # Set-up the required PHP configuration +sudo tee /etc/php/conf.d/churchcrm.ini << 'TXT' +file_uploads = On +allow_url_fopen = On +short_open_tag = On +memory_limit = 256M +upload_max_filesize = 100M +max_execution_time = 360 +TXT + +# Set-up the required Apache configuration sudo tee /etc/apache2/sites-available/churchcrm.conf << 'TXT' ServerAdmin webmaster@localhost -DocumentRoot /var/www/html/ +DocumentRoot /var/www/html/churchcrm/ +ServerName ChurchCRM - + Options -Indexes +FollowSymLinks AllowOverride All Require all granted @@ -53,10 +81,12 @@ CustomLog \${APACHE_LOG_DIR}/access.log combined TXT +# Enable apache rewrite module +sudo a2enmod rewrite + # Disable the default apache site and enable churchcrm sudo a2dissite 000-default.conf sudo a2ensite churchcrm.conf -# Restart apache to load new config -sudo systemctl restart apache2 - +# Restart apache to load new configuration +sudo systemctl restart apache2.service