#!/usr/bin/env bash exec > >(tee /root/installDependencies.log) if [ "$(lsb_release -si)" != "Debian" ]; then echo "Error: Designed to run on Debian. Running $(lsb_release -si) $(lsb_release -sc)" exit 1 fi sed -i 's/# export/export/g' .bashrc && sed -i 's/# eval/eval/g' .bashrc && sed -i 's/# alias/alias/g' .bashrc apt update # install PHP 8.4 dpkg -l | grep " php8.4 " | grep -q "^ii" if [ $? -ne 0 ]; then apt install -y apt-transport-https lsb-release ca-certificates curl gnupg2 if [ ! -f /etc/apt/trusted.gpg.d/sury-php.gpg ]; then curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-php.gpg fi if [ ! -f /etc/apt/sources.list.d/sury-php.list ]; then echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list apt update fi apt install -y php8.4 php8.4-cli php8.4-fpm php8.4-mysql php8.4-zip php8.4-xml php8.4-gd php8.4-curl php8.4-mbstring php8.4-bcmath php8.4-soap php8.4-readline php8.4-intl php8.4-common apt install -y php8.4-imagick php8.4-ldap php8.4-smbclient php8.4-imap php8.4-gmp php8.4-redis php8.4-memcached php8.4-apcu php8.4-bz2 php8.4-ssh2 php8.4-mcrypt phpd="$(php -i | grep "Scan this dir for additional .ini files" | awk '{print $NF}')" echo "memorylimit = -1" >> ${phpd}/99-nextcloud.ini echo "apc.enable_cli = On" >> ${phpd}/99-nextcloud.ini phpd="$(php -i | grep "Scan this dir for additional .ini files" | awk '{print $NF}' | sed 's#/cli/#/fpm/#')" echo "memorylimit = 1G" >> ${phpd}/99-nextcloud.ini echo "max_execution_time = 600" >> ${phpd}/99-nextcloud.ini echo "max_input_time = 600" >> ${phpd}/99-nextcloud.ini echo "sendmail_path = /usr/sbin/sendmail -t -i" >> ${phpd}/99-nextcloud.ini echo "opcache.jit = On" >> ${phpd}/99-nextcloud.ini echo "opcache.blacklist_filename = /var/www/example/*" >> ${phpd}/99-nextcloud.ini echo "opcache.interned_strings_buffer = 16" >> ${phpd}/99-nextcloud.ini echo "opcache.revalidate_freq = 20" >> ${phpd}/99-nextcloud.ini avgPHPProcessRamUsage=116 totalMem=$(free -m | awk '/Mem:/ {print $2}') # 1024M = 1G head room desiredMaxChidlren=$(($((totalMem - 1024)) / avgPHPProcessRamUsage)) wwwPool="$(php -i | grep "Scan this dir for additional .ini files" | awk '{print $NF}' | sed 's#/cli/#/fpm/#' | sed 's#/conf.d$##')/pool.d/www.conf" sed -i 's#^pm.max_children.*=.*#pm.max_children = '$desiredMaxChidlren'#g' ${wwwPool} sed -i 's#^.*env\[PATH\]#env\[PATH\]#g' ${wwwPool} systemctl enable php8.4-fpm.service systemctl restart php8.4-fpm.service fi # install Nginx dpkg -l | grep " nginx " | grep -q "^ii" if [ $? -ne 0 ]; then apt install -y nginx ssl-cert systemctl enable nginx systemctl restart nginx fi # memcached dpkg -l | grep " memcached " | grep -q "^ii" if [ $? -ne 0 ]; then apt install -y memcached systemctl enable memcached systemctl restart memcached fi # install MariaDB 11.4 dpkg -l | grep " mariadb-server " | grep -q "^ii" if [ $? -ne 0 ]; then case "$(lsb_release -sc)" in trixie) echo "Using debian provided" ;; *) if [ ! -f /etc/apt/keyrings/mariadb-keyring.pgp ]; then mkdir -p /etc/apt/keyrings curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp' fi if [ ! -f /etc/apt/sources.list.d/mariadb.sources ]; then curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup -O /tmp/mariadb_repo_setup bash /tmp/mariadb_repo_setup --mariadb-server-version="mariadb-11.rolling" --skip-check-installed --skip-tools --skip-maxscale --write-to-stdout > /etc/apt/sources.list.d/mariadb.sources apt update fi ;; esac apt install -y mariadb-server ## secure instalation if [ ! -f /root/.my.cnf ]; then rootpass=$(openssl rand -base64 12) mariadb-secure-installation < /root/.my.cnf [client] user=root password=$rootpass EOL chmod 600 /root/.my.cnf fi fi