#!/usr/bin/env bash

sed -i -r 's/([a-z]{2}.)?archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sed -i -r 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
apt update
DEBIAN_FRONTEND=noninteractive apt -y install tzdata
apt install php-cli \
php-redis \
php-luasandbox \
php-fpm \
php-common \
php-cli \
php-gd \
php-mysql \
php-mbstring \
php-curl \
php-xml \
php-zip \
php-json \
php-tokenizer \
php-fileinfo \
php-dom \
php-xmlwriter \
php-mysqli \
php-imagick \
php-simplexml \
php-sqlite3 \
composer -y

apt install supervisor -y

sed -i 's@listen = /run/php/php8.1-fpm.sock@listen = 0.0.0.0:9000@g' /etc/php/8.1/fpm/pool.d/www.conf

sed -i 's@post_max_size = 8M@post_max_size = 85M@g' /etc/php/8.1/fpm/php.ini
sed -i 's@upload_max_filesize = 2M@upload_max_filesize = 10M@g' /etc/php/8.1/fpm/php.ini
sed -i 's@memory_limit = 128M@memory_limit = 512M@g' /etc/php/8.1/fpm/php.ini