{"id":3942,"date":"2025-12-26T11:36:28","date_gmt":"2025-12-26T03:36:28","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3942"},"modified":"2026-03-13T10:50:40","modified_gmt":"2026-03-13T02:50:40","slug":"install-nextcloud-debian11-apache","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/install-nextcloud-debian11-apache","title":{"rendered":"9 Easy Steps to Install Nextcloud on Debian 11 with Apache"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3943\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-300x169.jpeg\" alt=\"Nextcloud\" width=\"914\" height=\"515\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/49-390x219.jpeg 390w\" sizes=\"(max-width: 914px) 100vw, 914px\" \/><\/p>\n<p>A powerful server environment is an excellent solution for running <strong data-start=\"596\" data-end=\"609\">Nextcloud<\/strong>, a widely used open-source platform for file storage, collaboration, and productivity. It allows users to host their own private cloud instead of relying on third-party services. With proper configuration, it can provide reliable performance for businesses, developers, and personal users who require secure data management.<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\">\n<p data-start=\"529\" data-end=\"934\">This guide explains how to install and configure the platform on a <strong data-start=\"1003\" data-end=\"1023\">Debian 11 server<\/strong> using <strong data-start=\"1030\" data-end=\"1059\">Apache2 as the web server<\/strong>. By following the steps below, you will be able to deploy a fully functional cloud storage system with database support and SSL security.<\/p>\n<p data-start=\"529\" data-end=\"934\">Before starting the installation, make sure your system packages are updated. Log in to your server as root and run the following command:<\/p>\n<p><code class=\"!whitespace-pre hljs language-bash\"><code class=\"!whitespace-pre hljs language-bash\"><\/code><\/code><code class=\"!whitespace-pre hljs language-bash\"><code class=\"!whitespace-pre hljs language-bash\"><\/code><\/code><code class=\"!whitespace-pre hljs language-bash\">apt update &amp;&amp; apt upgrade \u2013y<br \/>\n<\/code><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>Updating ensures that all packages are running the latest stable versions and reduces potential compatibility issues during installation.<\/p>\n<h4 data-start=\"1521\" data-end=\"1557\">Step 1: Install Required Packages<\/h4>\n<p data-start=\"1559\" data-end=\"1708\">The first step is installing the essential software required for the environment. This includes Apache, database software, and several utility tools.<\/p>\n<p data-start=\"1710\" data-end=\"1736\">Run the following command:<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">apt install apache2 unzip wget curl mariadb-client mariadb-server nano<br \/>\n<\/code><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>These packages provide the basic infrastructure needed for running a web-based cloud platform. Apache will handle web requests while MariaDB will manage the database that stores user data and configuration.<\/p>\n<h4 data-start=\"2031\" data-end=\"2057\">Step 2: Install PHP 8.0<\/h4>\n<p data-start=\"2059\" data-end=\"2148\">Since the platform is built using PHP, you must install PHP and several required modules.<\/p>\n<h4 data-start=\"2150\" data-end=\"2180\">2A: Add the PHP Repository<\/h4>\n<p data-start=\"2182\" data-end=\"2220\">First, add the trusted PHP repository:<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">apt-get install ca-certificates apt-transport-https software-properties-common -y<br \/>\n<span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-string\">\"deb https:\/\/packages.sury.org\/php\/ <span class=\"hljs-subst\">$(lsb_release -sc)<\/span> main\"<\/span> | <span class=\"hljs-built_in\">tee<\/span> \/etc\/apt\/sources.list.d\/sury-php.list<br \/>\napt install gnupg gnupg2 gnupg1 -y<br \/>\nwget -qO - https:\/\/packages.sury.org\/php\/apt.gpg | apt-key add -<br \/>\napt update &amp;&amp; apt upgrade -y<br \/>\n<\/code><\/div>\n<\/div>\n<div><\/div>\n<div>This repository provides newer PHP versions that are compatible with modern applications.<\/div>\n<div><\/div>\n<p><span style=\"color: #1d1d1d; font-family: Montserrat, sans-serif; font-size: 1.6429em; font-weight: 600; letter-spacing: -0.3px;\">2B: Install PHP and Required Modules<\/span><\/p>\n<p><span style=\"color: #1d1d1d; font-family: Montserrat, sans-serif; font-size: 1.6429em; letter-spacing: -0.3px;\">Install PHP together with its important extensions:<\/span><\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><code class=\"!whitespace-pre hljs language-bash\"><\/code><\/code><code class=\"!whitespace-pre hljs language-bash\">apt install php8.0 -y<br \/>\napt install libapache2-mod-php8.0 php8.0-{zip,xml,mbstring,gd,curl,imagick,intl,bcmath,gmp,cli,mysql,apcu,redis}<br \/>\n<\/code><\/div>\n<\/div>\n<p data-start=\"2882\" data-end=\"3002\">These modules enable additional features such as database connectivity, caching, file compression, and image processing.<\/p>\n<h4 data-start=\"3004\" data-end=\"3034\">2C: Configure PHP Settings<\/h4>\n<p data-start=\"3036\" data-end=\"3070\">Next, edit the configuration file:<\/p>\n<p>nano \/etc\/php\/8.0\/apache2\/php.ini<\/p>\n<p data-start=\"3115\" data-end=\"3181\">Adjust the following values according to your system requirements:<\/p>\n<ul data-start=\"3183\" data-end=\"3259\">\n<li data-start=\"3183\" data-end=\"3199\">\n<p data-start=\"3185\" data-end=\"3199\"><code data-start=\"3185\" data-end=\"3199\">memory_limit<\/code><\/p>\n<\/li>\n<li data-start=\"3200\" data-end=\"3223\">\n<p data-start=\"3202\" data-end=\"3223\"><code data-start=\"3202\" data-end=\"3223\">upload_max_filesize<\/code><\/p>\n<\/li>\n<li data-start=\"3224\" data-end=\"3241\">\n<p data-start=\"3226\" data-end=\"3241\"><code data-start=\"3226\" data-end=\"3241\">post_max_size<\/code><\/p>\n<\/li>\n<li data-start=\"3242\" data-end=\"3259\">\n<p data-start=\"3244\" data-end=\"3259\"><code data-start=\"3244\" data-end=\"3259\">date.timezone<\/code><\/p>\n<\/li>\n<\/ul>\n<p data-start=\"3261\" data-end=\"3326\">Increasing these limits is helpful when users upload large files.<\/p>\n<h4>Step 3: Create the Database<\/h4>\n<p data-start=\"3365\" data-end=\"3418\">Next, create a database for storing application data.<\/p>\n<p data-start=\"3420\" data-end=\"3435\">Access MariaDB:<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">mysql \u2013u root \u2013p<\/p>\n<p>Then run these commands:<\/p>\n<p>CREATE DATABASE nextcloud;<br \/>\nCREATE USER <span class=\"hljs-string\">'nextcloud'<\/span>@<span class=\"hljs-string\">'localhost'<\/span> IDENTIFIED BY <span class=\"hljs-string\">'PASSWORD'<\/span>;<br \/>\nGRANT ALL PRIVILEGES ON nextcloud.* TO <span class=\"hljs-string\">'nextcloud'<\/span>@<span class=\"hljs-string\">'localhost'<\/span>;<br \/>\nFLUSH PRIVILEGES;<br \/>\n<span class=\"hljs-built_in\">exit<\/span>;<br \/>\n<\/code><\/div>\n<\/div>\n<p>This creates a dedicated database and user account for the platform.<\/p>\n<h4 data-start=\"3750\" data-end=\"3791\">Step 4: Download the Application Files<\/h4>\n<p data-start=\"3793\" data-end=\"3859\">Download the latest release directly from the official repository.<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">cd<\/span> \/tmp &amp;&amp; wget https:\/\/download.nextcloud.com\/server\/releases\/latest.zip<br \/>\nunzip latest.zip<br \/>\n<span class=\"hljs-built_in\">rm<\/span> latest.zip<br \/>\n<span class=\"hljs-built_in\">mv<\/span> nextcloud \/var\/www<br \/>\n<\/code><\/div>\n<\/div>\n<p>This places the application files inside the web directory so Apache can access them.<\/p>\n<h4 data-start=\"4089\" data-end=\"4116\">Step 5: Configure Apache<\/h4>\n<p data-start=\"4118\" data-end=\"4181\">Enable necessary Apache modules to support the web application.<\/p>\n<p data-start=\"4118\" data-end=\"4181\">Enable Modules<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">a2enmod rewrite headers <span class=\"hljs-built_in\">env<\/span> <span class=\"hljs-built_in\">dir<\/span> mime<br \/>\n<\/code><\/div>\n<\/div>\n<h4 data-start=\"4249\" data-end=\"4274\">Create a Virtual Host<\/h4>\n<p data-start=\"4276\" data-end=\"4308\">Create a new configuration file:<\/p>\n<p><code class=\"!whitespace-pre hljs language-bash\">nano \/etc\/apache2\/sites-available\/nextcloud.conf<\/code><\/p>\n<p data-start=\"4368\" data-end=\"4450\">Insert the required VirtualHost configuration and update it with your domain name.<\/p>\n<p data-start=\"4452\" data-end=\"4502\">After saving the file, activate the configuration:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute end-1.5 top-1 z-2 md:end-2 md:top-1\"><\/div>\n<div class=\"pe-11 pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\"><code class=\"!whitespace-pre hljs language-bash\">a2ensite nextcloud.conf<br \/>\nsystemctl restart apache2<\/code><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4 data-start=\"4568\" data-end=\"4609\">Step 6: Create Optional Data Directory<\/h4>\n<p data-start=\"4611\" data-end=\"4707\">If you prefer storing uploaded files in a different location, create a dedicated data directory.<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">mkdir<\/span> \/home\/data<br \/>\n<\/code><\/div>\n<\/div>\n<p data-start=\"4735\" data-end=\"4814\">Separating the storage directory can improve organization and simplify backups.<\/p>\n<h4>\nStep 7: Permission Adjustments<\/h4>\n<p>Correct permissions are necessary for the web server to access the files.<\/p>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">chown<\/span> -R www-data:www-data \/var\/www\/nextcloud<br \/>\n<span class=\"hljs-built_in\">chmod<\/span> -R 755 \/var\/www\/nextcloud<br \/>\n<span class=\"hljs-built_in\">chown<\/span> \u2013R www-data:www-data \/home\/data  <span class=\"hljs-comment\"># Adjust if using a different location<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<p>This ensures Apache can read and write the required directories.<\/p>\n<h4 data-start=\"5125\" data-end=\"5159\">Step 8: Install SSL Certificate<\/h4>\n<p data-start=\"5161\" data-end=\"5230\">To secure user connections, install an SSL certificate using Certbot.<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pe-11 pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"bg-black rounded-md\">\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">apt install certbot python3-certbot-apache -y<br \/>\ncertbot --apache<br \/>\n<\/code><\/div>\n<\/div>\n<p>Follow the prompts and select your domain name. After completion, HTTPS will automatically be configured.<\/p>\n<h4 data-start=\"5416\" data-end=\"5460\">Step 9: Complete Installation via Browser<\/h4>\n<p data-start=\"5462\" data-end=\"5516\">Open your domain in a web browser to finish the setup.<\/p>\n<p data-start=\"5518\" data-end=\"5550\">During the installation process:<\/p>\n<ol data-start=\"5552\" data-end=\"5770\">\n<li data-start=\"5552\" data-end=\"5590\">\n<p data-start=\"5555\" data-end=\"5590\">Create an <strong data-start=\"5565\" data-end=\"5590\">administrator account<\/strong><\/p>\n<\/li>\n<li data-start=\"5591\" data-end=\"5640\">\n<p data-start=\"5594\" data-end=\"5640\">Choose the <strong data-start=\"5605\" data-end=\"5629\">data folder location<\/strong> (optional)<\/p>\n<\/li>\n<li data-start=\"5641\" data-end=\"5770\">\n<p data-start=\"5644\" data-end=\"5671\">Enter database information:<\/p>\n<ul data-start=\"5675\" data-end=\"5770\">\n<li data-start=\"5675\" data-end=\"5703\">\n<p data-start=\"5677\" data-end=\"5703\">Database User: <code data-start=\"5692\" data-end=\"5703\">nextcloud<\/code><\/p>\n<\/li>\n<li data-start=\"5707\" data-end=\"5738\">\n<p data-start=\"5709\" data-end=\"5738\">Database Password: <code data-start=\"5728\" data-end=\"5738\">PASSWORD<\/code><\/p>\n<\/li>\n<li data-start=\"5742\" data-end=\"5770\">\n<p data-start=\"5744\" data-end=\"5770\">Database Name: <code data-start=\"5759\" data-end=\"5770\">nextcloud<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p data-start=\"5772\" data-end=\"5825\">Click <strong data-start=\"5778\" data-end=\"5789\">Install<\/strong> and wait for the setup to complete.<\/p>\n<p data-start=\"5827\" data-end=\"5919\">Once finished, the dashboard will appear and the private cloud system will be ready for use.<\/p>\n<p>If you need step-by-step guidance on setting up Nextcloud, you can visit <a href=\"https:\/\/www.servergigabit.com\/guide\/kb\/nextcloud-guide-to-setting-up-server-gigabit\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A powerful server environment is an excellent solution for running Nextcloud, a widely used open-source platform for file storage, collaboration, and productivity. It allows users to host their own private cloud instead of relying on third-party services. With proper configuration, it can provide reliable performance for businesses, developers, and personal users who require secure data management. This guide explains how&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1153],"class_list":["post-3942","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-nextcloud"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3942"}],"version-history":[{"count":5,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3942\/revisions"}],"predecessor-version":[{"id":6236,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3942\/revisions\/6236"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3942"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3942"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}