Zum Inhalt springen

Install Nextcloud on Debian 12

Nextcloud is a powerful open-source solution for hosting your files, calendars, contacts, and much more, all on your own server. Here is a step-by-step guide to installing Nextcloud on a Debian 12 machine.

Step 1: Update your system

Start by ensuring that your system is up to date:

sudo apt-get update && sudo apt-get upgrade -y

Step 2: Installation and Configuration of Apache

Install the Apache web server:

sudo apt install apache2 -y

Enable Apache to start automatically at boot:

sudo systemctl is-enabled apache2

Check that the service is active:

sudo systemctl status apache2

Step 3: Configure the firewall with UFW

Install UFW (Uncomplicated Firewall) to secure your server:

sudo apt install ufw

Allow SSH connections and enable the firewall:

sudo ufw allow OpenSSH sudo ufw enable

Allow HTTP and HTTPS connections:

sudo ufw allow "WWW Full" sudo ufw reload

Check the status of the firewall:

sudo ufw status

Step 4: Install PHP and its required modules

Nextcloud requires PHP and several modules. Install them with a single command:

sudo apt install -y php php-curl php-cli php-mysql php-gd php-common php-xml php-json php-intl php-pear php-imagick php-dev php-mbstring php-zip php-soap php-bz2 php-bcmath php-gmp php-apcu libmagickcore-dev php-redis php-memcached

Check the PHP version and the installed modules:

php --version php -m

Step 5: Configure PHP

Edit the PHP configuration file to optimize performance and adjust the necessary limits for Nextcloud:

sudo nano /etc/php/8.2/apache2/php.ini

Modify the following settings:

date.timezone = Europe/Zurich memory_limit = 4096M upload_max_filesize = 100000M post_max_size = 100000M max_execution_time = 3600 file_uploads = On allow_url_fopen = On display_errors = Off output_buffering = Off zend_extension=opcache opcache.enable = 1 opcache.interned_strings_buffer = 64 opcache.max_accelerated_files = 10000 opcache.memory_consumption = 128 opcache.save_comments = 1 opcache.revalidate_freq = 1

Restart Apache to apply the changes:

sudo systemctl restart apache2

Step 6: Install and configure MariaDB

Install MariaDB:

sudo apt install mariadb-server -y

Make sure it is enabled:

sudo systemctl is-enabled mariadb

Check its status:

sudo systemctl status mariadb

Configure MariaDB with the security assistant:

sudo mariadb-secure-installation

Create a database and a user for Nextcloud:

sudo mariadb -u root -p CREATE DATABASE nextcloud_db; CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'StrongPassword'; GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextclouduser'@'localhost'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'nextclouduser'@'localhost'; quit

Step 7: Download and configure Nextcloud

Install the necessary tools:

sudo apt install curl unzip -y

Download and unzip Nextcloud:

cd /var/www/ curl -o nextcloud.zip https://download.nextcloud.com/server/releases/latest.zip unzip nextcloud.zip

Make sure that the permissions are correctly set:

sudo chown -R www-data:www-data nextcloud

Step 8: Configure Apache for Nextcloud

Create a configuration file for the Nextcloud site:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Add the following content, adjusting the details such as the domain name:

<VirtualHost *:80> ServerName cloud.ait.hosting DocumentRoot /var/www/nextcloud/ ErrorLog /var/log/apache2/files.cloud.ait.hosting-error.log CustomLog /var/log/apache2/files.cloud.ait.hosting-access.log combined <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory> </VirtualHost>

Activate the site and restart Apache:

sudo a2ensite nextcloud.conf sudo apachectl configtest sudo systemctl restart apache2

Step 9: Secure with Certbot

Install Certbot to generate an SSL certificate:

sudo apt install certbot python3-certbot-apache

Run Certbot to configure HTTPS:

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email admin@ait.hosting -d cloud.ait.hosting

Conclusion

Your Nextcloud installation on Debian 12 is now complete. Access your server via the browser using the configured URL (for example, https://cloud.ait.hosting), and follow the on-screen instructions to finalize the setup. 🎉

   

Cron job

Create a new crontab that will be used to run the Nextcloud crontab script


sudo crontab -u www-data -e


Add the following configuration to the crontab file


*/5  *  *  *  * php --define apc.enable_cli=1 -f /var/www/nextcloud/cron.php


Save and exit the file


Bonus

Open the Nextcloud configuration file /var/www/nextcloud/config/config.php


sudo nano /var/www/nextcloud/config/config.php


and add these commands


'memcache.local' => '\OC\Memcache\APCu',  
'default_phone_region' => 'ch', 
'maintenance_window_start' => 1,


Save the changes and close the file when you are done


OCC Commandes

May be useful

/var/www/nextcloud$ sudo -u www-data php --define apc.enable_cli=1  /var/www/nextcloud/occ maintenance:repair --include-expensive
sudo -u www-data php --define apc.enable_cli=1  /var/www/nextcloud/occ db:add-missing-indices
sudo -u www-data php --define apc.enable_cli=1  /var/www/nextcloud/occ db:add-missing-columns
sudo -u www-data php --define apc.enable_cli=1  /var/www/nextcloud/occ db:add-missing-primary-keys



Bewertung
1 0

Momentan sind keine Kommentare vorhanden.

, um als erster einen Kommentar zu hinterlassen.