#!/bin/bash # Update system packages sudo apt update sudo apt upgrade -y # Install required packages sudo apt install -y apache2 mariadb-server libapache2-mod-php7.4 php7.4-gd php7.4-json php7.4-mysql php7.4-curl php7.4-mbstring php7.4-intl php7.4-xml php7.4-zip php7.4-bz2 php7.4-common php7.4-cli php7.4-ldap php7.4-gmp # Enable necessary Apache modules sudo a2enmod rewrite sudo a2enmod headers sudo a2enmod env sudo a2enmod dir sudo a2enmod mime # Create a database for Nextcloud sudo mysql -u root -p < ServerAdmin webmaster@localhost DocumentRoot /var/www/nextcloud ServerName your_domain_or_ip_here ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Options +FollowSymlinks AllowOverride All Require all granted Dav off SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud EOF # Enable the Nextcloud virtual host sudo a2ensite nextcloud.conf # Restart Apache sudo systemctl restart apache2 # Set up Nextcloud cron job sudo -u www-data php /var/www/nextcloud/cron.php # Clean up rm latest.tar.bz2 echo "Nextcloud installation is complete. Access your Nextcloud instance by visiting http://your_domain_or_ip_here in your web browser."