Installation
for debian 12!
cat << EOF > /etc/apt/sources.list
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
EOF
apt update -y
apt full-upgrade -y
apt-mark hold apache2 apache2-bin
apt install -y --no-install-recommends php php-{fpm,ctype,curl,dom,fileinfo,gd,mbstring,xml,xmlreader,xmlwriter,zip,sqlite3,mysql,pgsql,intl,ldap,ftp,imap,bcmath,gmp,exif,apcu,memcached,redis,imagick,phar} ffmpeg nginx aria2 curl wget unzip bzip2 p7zip p7zip-full postgresql redis
# PHP Tuning
PHP_VERSION="8.2"
files=(
"/etc/php/$PHP_VERSION/mods-available/apcu.ini"
"/etc/php/$PHP_VERSION/cli/conf.d/20-apcu.ini"
"/etc/php/$PHP_VERSION/fpm/conf.d/20-apcu.ini"
)
for file in "${files[@]}"; do grep -q "^apc.enable_cli.*" "$file" && sed -i 's/^apc.enable_cli.*/apc.enable_cli=1/' "$file" || echo "apc.enable_cli=1" >> "$file"; done
sed -i 's/.*max_input_time.*/max_input_time=3600/' /etc/php/$PHP_VERSION/cli/php.ini
sed -i 's/.*max_input_time.*/max_input_time=3600/' /etc/php/$PHP_VERSION/fpm/php.ini
sed -i 's/.*max_execution_time.*/max_execution_time=3600/' /etc/php/$PHP_VERSION/cli/php.ini
sed -i 's/.*max_execution_time.*/max_execution_time=3600/' /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*memory_limit.*/memory_limit=512M/" /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*memory_limit.*/memory_limit=512M/" /etc/php/$PHP_VERSION/cli/php.ini
sed -i "s/.*opcache.enable=.*/opcache.enable=1/" /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*opcache.enable=.*/opcache.enable=1/" /etc/php/$PHP_VERSION/cli/php.ini
sed -i "s/.*opcache.enable_cli=.*/opcache.enable_cli=1/" /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*opcache.enable_cli=.*/opcache.enable_cli=1/" /etc/php/$PHP_VERSION/cli/php.ini
sed -i "s/.*post_max_size.*/post_max_size=200G/" /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*post_max_size.*/post_max_size=200G/" /etc/php/$PHP_VERSION/cli/php.ini
sed -i "s/.*upload_max_filesize.*/upload_max_filesize=200G/" /etc/php/$PHP_VERSION/fpm/php.ini
sed -i "s/.*upload_max_filesize.*/upload_max_filesize=200G/" /etc/php/$PHP_VERSION/cli/php.ini
# PostgreSQL
PG_PASSWORD=$(openssl rand -base64 12)
SQL_COMMANDS=$(cat <<EOF
CREATE DATABASE nextcloud;
DO \$\$
DECLARE
random_password text;
BEGIN
SELECT gen_random_uuid()::text INTO random_password;
EXECUTE 'CREATE USER nextcloud WITH PASSWORD ''' || '${PG_PASSWORD}' || '''';
END \$\$;
GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
CREATE SCHEMA IF NOT EXISTS public;
GRANT USAGE ON SCHEMA public TO nextcloud;
EOF
)
echo "${SQL_COMMANDS}" | sudo -u postgres psql
cat << EOF
--- [PostgreSQL] ---
User: nextcloud
Database: nextcloud
Password: ${PG_PASSWORD}
# Bitte Speichern, auch wenn es warscheinlich nicht mehr benötigt wird.
EOF
# Redis
REDIS_PASSWORD=$(openssl rand -base64 12)
sed -i 's/.*port 6379.*/port 0/' /etc/redis/redis.conf
sed -i "s/.*unixsocket .*/unixsocket \/run\/redis\/redis-server.sock/" /etc/redis/redis.conf
sed -i 's/.*unixsocketperm .*/unixsocketperm 770/' /etc/redis/redis.conf
sed -i 's/.*maxclients .*/maxclients 10240/' /etc/redis/redis.conf
sed -i "s/.*requirepass foobared.*/requirepass $(echo "$REDIS_PASSWORD" | sed -e 's/[\/&]/\\&/g')/" /etc/redis/redis.conf
usermod -aG redis www-data
service redis-server restart
cat << EOF
--- [REDIS] ---
Unixsocket:
Database: nextcloud
Password: ${PG_PASSWORD}REDIS_PASSWORD}
# Bitte Speichern, auch wenn es warscheinlich nicht mehr benötigt wird.
EOF