#!/bin/sh
sudo ufw disable
sudo systemctl disable ufw
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y unzip
sudo apt install -y apache2 apache2-utils
sudo apt install -y php8.1 libapache2-mod-php8.1
sudo apt install -y php8.1-common php8.1-pgsql php8.1-mysql php8.1-gd php8.1-zip php8.1-xml php8.1-cli php8.1-mbstring php8.1-curl php8.1-sqlite3 php8.1-apcu php8.1-bcmath php8.1-gmp php8.1-imagick php8.1-intl
sudo wget -O /usr/lib/php/20210902/ixed.8.1.lin https://scsus.com.br/ext/linux/x86_64/ixed.8.1.lin
sudo sed -i 's/max_execution_time = 30/max_execution_time = 0/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/memory_limit = 128M/memory_limit = -1/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's+;date.timezone =+date.timezone = America/Sao_Paulo+g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=curl/extension=curl/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=fileinfo/extension=fileinfo/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=gd/extension=gd/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=mbstring/extension=mbstring/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=pdo_mysql/extension=pdo_mysql/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=pdo_pgsql/extension=pdo_pgsql/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=shmop/extension=ixed.8.1.lin/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/;extension=bz2/extension=bz2/g' /etc/php/8.1/apache2/php.ini
sudo sed -i 's/output_buffering = 4096/output_buffering = Off/g' /etc/php/8.1/apache2/php.ini
sudo phpenmod -v 8.1 bcmath gmp imagick intl
sudo systemctl enable apache2
sudo systemctl start apache2
sudo apt install -y mysql-server
sudo systemctl enable mysql
sudo systemctl start mysql
sudo mysql -u root -Bse "alter user 'root'@'localhost' identified with mysql_native_password by '123456';"
sudo wget -O /var/www/html/scsus.zip https://scsus.com.br/scsus.zip
sudo unzip /var/www/html/scsus.zip -d /var/www/html
sudo chmod 777 -R /var/www/html/scsus
sudo a2dismod php*
sudo a2enmod php8.1
sudo update-alternatives --set php /usr/bin/php8.1
sudo update-alternatives --set phar /usr/bin/phar8.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.1
sudo update-alternatives --set phpize /usr/bin/phpize8.1
sudo update-alternatives --set php-config /usr/bin/php-config8.1
sudo rm -rf /var/www/html/scsus.zip
sudo service apache2 restart
