Skip to content

Commit

Permalink
WIP: Fix ubuntu.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
respencer committed May 26, 2024
1 parent ca49fd1 commit e69d552
Showing 1 changed file with 72 additions and 42 deletions.
114 changes: 72 additions & 42 deletions install/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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'
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
DocumentRoot /var/www/html/churchcrm/
ServerName ChurchCRM
<Directory /var/www/html/>
<Directory /var/www/html/churchcrm/>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
Expand All @@ -53,10 +81,12 @@ CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
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

0 comments on commit e69d552

Please sign in to comment.