112 lines
3.6 KiB
Bash
112 lines
3.6 KiB
Bash
#!/bin/bash
|
|
#Script created by Andrzej "Ferex" Szczepaniak
|
|
#Thanks for Jakub "Unknow" Mrugalski, Marcin "y0rune" Wozniak, Mariusz "maniek205" Kowalski and Paweł aka "./lemon.sh" for help
|
|
set -euo pipefail
|
|
|
|
apt update && apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2
|
|
|
|
os_check=$(cat /etc/os-release | grep "^ID=")
|
|
if [[ $os_check == "ID=debian" ]] ;
|
|
then
|
|
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
|
|
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
|
|
elif [[ $os_check == "ID=ubuntu" ]] ;
|
|
then
|
|
apt-add-repository ppa:ondrej/php -y
|
|
apt-add-repository ppa:ondrej/apache2 -y
|
|
fi
|
|
|
|
apt update
|
|
|
|
apt install -y apache2 libapache2-mod-fcgid php7.4-fpm php7.4-memcached php7.4-memcache memcached libmemcached-tools openssl wget php7.4-imagick php7.4-xml php7.4-intl php7.4-dom php7.4-mysqli php7.4-sqlite3 php7.4-gd php7.4-mbstring php7.4-common php7.4-curl php7.4-gd php7.4-imap php7.4-intl php7.4-mbstring php7.4-mysql php7.4-ssh2 php7.4-xml php7.4-zip php7.4-apcu php7.4-ldap php7.4-gmp php7.4-pgsql libmagickcore-6.q16-6-extra
|
|
a2enmod dir env headers mime rewrite setenvif ssl proxy proxy_fcgi
|
|
a2dismod mpm_prefork
|
|
a2enmod mpm_event
|
|
a2enconf php7.4-fpm
|
|
phpenmod -v 7.4 apcu memcache
|
|
echo "apc.enable_cli=1" >> /etc/php/7.4/cli/php.ini
|
|
echo "apc.enable_cli=1" >> /etc/php/7.4/fpm/php.ini
|
|
|
|
crontab -l > /tmp/crontasks
|
|
|
|
if [[ -d "/storage" ]]; then
|
|
if [[ -d "/storage/nextcloud/" ]]; then
|
|
if [ "$(ls -A /storage/nextcloud)" ]; then
|
|
mv /storage/nextcloud /storage/nextcloud-old
|
|
fi
|
|
rm -rf /storage/nextcloud
|
|
fi
|
|
cd /storage && wget https://download.nextcloud.com/server/releases/latest.tar.bz2 -O nextcloud.tar.bz2
|
|
cd /storage && tar -xf nextcloud.tar.bz2
|
|
cd /storage && rm nextcloud.tar.bz2
|
|
chown -R www-data:www-data /storage/nextcloud
|
|
|
|
cat > /etc/apache2/sites-available/nextcloud.conf <<\EOL
|
|
Alias /nextcloud "/storage/nextcloud"
|
|
<Directory /storage/nextcloud>
|
|
Options +FollowSymlinks
|
|
AllowOverride All
|
|
Require all granted
|
|
</Directory>
|
|
EOL
|
|
|
|
cat > /storage/nextcloud/config/autoconfig.php <<\EOL
|
|
<?php
|
|
$AUTOCONFIG = [
|
|
"directory" => "/storage/nextcloud/data",
|
|
];
|
|
EOL
|
|
|
|
cat > /storage/nextcloud/config/memcache.config.php <<\EOL
|
|
<?php
|
|
$_SERVER['HTTPS'] = 'on';
|
|
$CONFIG = array (
|
|
'memcache.local' => '\OC\Memcache\APCu',
|
|
'filelocking.enabled' => 'true',
|
|
'memcache.locking' => '\OC\Memcache\APCu',
|
|
);
|
|
EOL
|
|
|
|
echo "*/5 * * * * sudo -u www-data /usr/bin/php --define apc.enable_cli=1 -f /storage/nextcloud/cron.php" >> /tmp/crontasks
|
|
|
|
else
|
|
cd /var/www/html && wget https://download.nextcloud.com/server/releases/latest.tar.bz2 -O nextcloud.tar.bz2
|
|
cd /var/www/html && tar -xf nextcloud.tar.bz2
|
|
cd /var/www/html && rm nextcloud.tar.bz2
|
|
chown -R www-data:www-data /var/www/html
|
|
|
|
cat > /etc/apache2/sites-available/nextcloud.conf <<\EOL
|
|
Alias /nextcloud "/var/www/html/nextcloud"
|
|
<Directory /var/www/html/nextcloud>
|
|
Options +FollowSymlinks
|
|
AllowOverride All
|
|
Require all granted
|
|
</Directory>
|
|
EOL
|
|
|
|
cat > /var/www/html/nextcloud/config/autoconfig.php <<\EOL
|
|
<?php
|
|
$AUTOCONFIG = [
|
|
"directory" => "/var/www/html/nextcloud/data",
|
|
];
|
|
EOL
|
|
|
|
cat > /var/www/html/nextcloud/config/memcache.config.php <<\EOL
|
|
<?php
|
|
$_SERVER['HTTPS'] = 'on';
|
|
$CONFIG = array (
|
|
'memcache.local' => '\OC\Memcache\APCu',
|
|
'filelocking.enabled' => 'true',
|
|
'memcache.locking' => '\OC\Memcache\APCu',
|
|
);
|
|
EOL
|
|
|
|
echo "*/5 * * * * sudo -u www-data /usr/bin/php --define apc.enable_cli=1 -f /var/www/html/nextcloud/cron.php" >> /tmp/crontasks
|
|
|
|
fi
|
|
|
|
crontab /tmp/crontasks
|
|
rm /tmp/crontasks
|
|
a2ensite nextcloud
|
|
systemctl restart apache2
|