{"id":58,"date":"2022-05-12T13:27:43","date_gmt":"2022-05-12T20:27:43","guid":{"rendered":"https:\/\/www.cmsws.com\/blog\/?p=58"},"modified":"2023-05-27T05:53:15","modified_gmt":"2023-05-27T12:53:15","slug":"how-to-install-nextcloud-on-debian-11","status":"publish","type":"post","link":"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/","title":{"rendered":"Install NextCloud"},"content":{"rendered":"\n<p>How to Install NextCloud on Debian 11.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_1_Prepare_you_Debian_server\" >Step 1: Prepare you Debian server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_2_Install_PostgreSQL_create_database_create_user\" >Step 2: Install PostgreSQL, create database, create user<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_3_Install_and_configure_Apache\" >Step 3: Install and configure Apache<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_4_Install_and_configure_PHP\" >Step 4: Install and configure PHP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_5_Download_and_extract_NextCloud\" >Step 5: Download and extract NextCloud<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_6_Install_NextCloud\" >Step 6: Install NextCloud<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_7_Install_Recommended_apps\" >Step 7: Install Recommended apps<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_8_Post_install_settings\" >Step 8: Post install settings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_9_Create_a_new_group\" >Step 9: Create a new group<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_10_Create_a_new_system_user\" >Step 10: Create a new system user<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_11_Add_email_account_to_new_user\" >Step 11: Add email account to new user<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Step_12_Setup_mobile_device\" >Step 12: Setup mobile device<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-install-nextcloud-on-debian-11\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>Today I&#8217;m documenting the installing process for the latest version of NextCloud.  I will be installing this on Debian 11.  I will use Apache w\/PHP as the web server and PostgreSQL as the database.<\/p>\n\n\n\n<p>NextCloud is a self-hosted alternative to Dropbox and Google Drive.  It is made up from a set of server &amp; client applications.  With NextCloud you can store various media types all in a central storage location.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Prepare_you_Debian_server\"><\/span>Step 1: Prepare you Debian server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>After initial installation is complete log in via ssh as root and update the OS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update\napt upgrade<\/code><\/pre>\n\n\n\n<p>Install &#8220;sudo&#8221;. The add the user you created during the install to the sudoers group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install sudo\nusermod -Gsudo &lt;your_username&gt;<\/code><\/pre>\n\n\n\n<p>The standard Debian 11 package repositories do not have packages for NextCloud.  Therefor we will install NextCloud using the latest source release. But first, we must install all required dependencies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Install_PostgreSQL_create_database_create_user\"><\/span>Step 2: Install PostgreSQL, create database, create user<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>As a database is required, I will be using PostgreSQL 13.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install postgresql<\/code><\/pre>\n\n\n\n<p>Now, lets create the database, user account and assign permissions.  In my case, I&#8217;m calling the database and username both &#8220;nextcloud&#8221;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sudo -u postgres psql\npostgres=# CREATE USER nextcloud WITH ENCRYPTED PASSWORD 'your_password';\npostgres=# CREATE DATABASE nextcloud OWNER nextcloud TEMPLATE template0 ENCODING UTF8;\npostgres=# \\q<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Install_and_configure_Apache\"><\/span>Step 3: Install and configure Apache<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>NextCloud needs a web server to server the GUI.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2<\/code><\/pre>\n\n\n\n<p>Force the redirection of http to https with the following modifications.  Enable the mod_rewrite module and configure your VirtualHost in Apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2enmod rewrite\n\nsudo vi \/etc\/apache2\/sites-available\/000-default.conf\n\n# Add this before the closing &lt;\/VirtualHost&gt; block, Save, Exit\n\n        RewriteEngine   on\n        RewriteCond     %{SERVER_PORT} ^80$\n        RewriteCond     %{REMOTE_ADDR} !^127.0.0.1$\n        RewriteCond     %{REMOTE_ADDR} !^\\:\\:1$\n        RewriteRule     ^\/(.*)$ https:\/\/%{SERVER_NAME}\/$1 &#91;L,R]<\/code><\/pre>\n\n\n\n<p>Restart Apache<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart apache2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Install_and_configure_PHP\"><\/span>Step 4: Install and configure PHP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>NextCloud requires a number of PHP packages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php php-bcmath php-cgi php-cli php-common php-curl php-gd  php-gmp php-imagick php-intl php-ldap php-mbstring php-memcache php-pgsql php-xml php-zip libapache2-mod-php<\/code><\/pre>\n\n\n\n<p>The PHP configuration needs a little tweaking for your environment.  NextCloud has recommended configuration changes for PHP.<\/p>\n\n\n\n<p>Edit your php.ini file for apache:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n<p>Below are configuration variables that need to be updated to fix your environment.  Update according to your needs.  Refer to <a href=\"https:\/\/www.php.net\/manual\/en\/timezones.php\">https:\/\/www.php.net\/manual\/en\/timezones.php<\/a> for a list of available values for the date.timezone variable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>date.timezone = America\/Los_Angeles\nmemory_limit = 512M\nupload_max_filesize = 200M\npost_max_size = 200M\nmax_execution_time = 600\n;output_buffering = 4096 ; Comment this out<\/code><\/pre>\n\n\n\n<p>Depending on the NextCloud apps you choose to install, additional packages may be needed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_5_Download_and_extract_NextCloud\"><\/span>Step 5: Download and extract NextCloud<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Grab the current release of NextCloud from their release folder.  Extract the contents of latest.tar.bz2 using tar.  Remove the source file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/download.nextcloud.com\/server\/releases\/latest.tar.bz2\ntar xf latest.tar.bz2\nrm latest.tar.bz2<\/code><\/pre>\n\n\n\n<p>Set permissions and move the folder to the Apache web folder.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R www-data:www-data nextcloud\/\nsudo chmod -R 755 nextcloud\/\nsudo mv nextcloud\/ \/var\/www\/html\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_6_Install_NextCloud\"><\/span>Step 6: Install NextCloud<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Using your browser of choice, browse to your newly created and installed server IP address: <strong><em>http:\/\/&lt;IP_ADDRESS&gt;\/nextcloud\/<\/em><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"1024\" src=\"https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/NextCloud-Web-install-screen-489x1024.png\" alt=\"\" class=\"wp-image-61\" srcset=\"https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/NextCloud-Web-install-screen-489x1024.png 489w, https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/NextCloud-Web-install-screen-143x300.png 143w, https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/NextCloud-Web-install-screen.png 571w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><figcaption class=\"wp-element-caption\">NextCloud setup screen<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_7_Install_Recommended_apps\"><\/span>Step 7: Install Recommended apps<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If everything goes as planned, you should be presented with a page asking you to install all recommended apps.  If you want these, click the &#8220;Install recommended apps&#8221; button at the bottom of the page.  You should see a little spinning progress indicator to the right of each apps name as it is being installed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"726\" height=\"843\" src=\"https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/nextcloud-install-recommended-apps.png\" alt=\"\" class=\"wp-image-62\" srcset=\"https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/nextcloud-install-recommended-apps.png 726w, https:\/\/www.cmsws.com\/blog\/wp-content\/uploads\/2022\/05\/nextcloud-install-recommended-apps-258x300.png 258w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><figcaption class=\"wp-element-caption\">Install recommended apps<\/figcaption><\/figure>\n\n\n\n<p>You will be redirect to the dash board after the installation is complete.  If errors were encountered during the installation process they will be displayed under their associated apps heading.<\/p>\n\n\n\n<p>The following can be completed after the initial configuration of NextCloud.  To ensure that your NextCloud instance is secure we need to enforce the use of https.  Now would be a good time time to update the NextCloud configuration file with the correct hostname for your server.<\/p>\n\n\n\n<p>Open &#8216;\/var\/www\/html\/nextcloud\/config\/config.php&#8217; and follow along:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/var\/www\/html\/nextcloud\/config\/config.php\n\n# update the following\n 'overwrite.cli.url' =&gt; 'https:\/\/&lt;hostname.tld&gt;\/nextcloud',\n\n# insert this line\n 'overwriteprotocol' =&gt; 'https',<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_8_Post_install_settings\"><\/span>Step 8: Post install settings<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First, as your admin user, go to user Settings -&gt; Administration -&gt; Overview.  The system will perform some checks and provide details about Security &amp; setup warnings.  Read through these warnings and try fixing everything that comes up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_9_Create_a_new_group\"><\/span>Step 9: Create a new group<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Log into NextCloud with your Admin account.  Click on your profile picture and click on Users.  Click the &#8220;Add Group&#8221; button.  Enter the name of the group.  Click the right arrow [-&gt;] button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_10_Create_a_new_system_user\"><\/span>Step 10: Create a new system user<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p> Click &#8220;New User&#8221;.  Add the details for your new user.  Click &#8220;Add a new user&#8221;.   Done!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_11_Add_email_account_to_new_user\"><\/span>Step 11: Add email account to new user<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Follow these steps to add an email account to the newly created user account:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Login to NextCloud with the new users credentials<\/li>\n\n\n\n<li>Click the envelope with the label of Mail in the top tool bar<\/li>\n\n\n\n<li>Enter your &#8220;Display Name&#8221;, email address and password<\/li>\n\n\n\n<li>Click &#8220;Connect&#8221;<\/li>\n<\/ul>\n\n\n\n<p>If everything worked, you should be redirected to a new page where you see the contents of your email account.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_12_Setup_mobile_device\"><\/span>Step 12: Setup mobile device<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install the mobile app just as you would any other app from your app or play store.  Search for NextCloud and make sure the author is NextCloud.  After you have the app installed, you will need to provide the URL for the NextCloud server and your username and password.<\/p>\n\n\n\n<p>After you have entered these details, you will be presented with the documents and file available in your profile.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Hope this wasn&#8217;t too painful.  Let me know if you have any questions or suggestions for improvement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install NextCloud on Debian 11. Today I&#8217;m documenting the installing process for the latest version of NextCloud. I will be installing this on Debian 11. I will use Apache w\/PHP as the web server and PostgreSQL as the database. NextCloud is a self-hosted alternative to Dropbox and Google Drive. It is made up from a set of server [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,25],"tags":[19,15,11,20],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-cloud-computing","category-linux","tag-apache-web-server","tag-debian","tag-php","tag-postgresql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":15,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":177,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions\/177"}],"wp:attachment":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}