{"id":111,"date":"2018-09-04T21:10:57","date_gmt":"2018-09-04T21:10:57","guid":{"rendered":"https:\/\/luroclab.com\/?p=111"},"modified":"2020-05-08T04:52:14","modified_gmt":"2020-05-08T04:52:14","slug":"install-nextcloud-on-ubuntu-16-04","status":"publish","type":"post","link":"https:\/\/badasscybersecurity.com\/?p=111","title":{"rendered":"Install Nextcloud on Ubuntu 16.04"},"content":{"rendered":"<p><a href=\"https:\/\/nextcloud.com\/\">Nextcloud<\/a>, a fork of ownCloud, is a file sharing server that permits you to store your personal content, like documents and pictures, in a centralized location, much like Dropbox. The difference with Nextcloud is that all of its features are open-source. It also returns the control and security of your sensitive data back to you, thus eliminating the use of a third-party cloud hosting service.<\/p>\n<h2 id=\"step-1-\u2013-installing-nextcloud\">Step 1 \u2013 Installing Nextcloud<\/h2>\n<p>We will be installing Nextcloud using the&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Snappy_(package_manager)\">snappy<\/a>&nbsp;packaging system. This packaging system, available on Ubuntu 16.04 by default, allows organizations to ship software, along with all associated dependencies and configuration, in a self-contained unit with automatic updates. This means that instead of installing and configuring a web and database server and then configuring the Nextcloud app to run on it, we can install the&nbsp;<span style=\"font-family: Courier New;\"><code>snap<\/code><\/span>&nbsp;package which handles the underlying systems automatically.<\/p>\n<p>To download the Nextcloud&nbsp;<span style=\"font-family: Courier New;\"><code>snap<\/code><\/span>&nbsp;package and install it on the system, type:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;snap&nbsp;install&nbsp;nextcloud<\/code><\/pre>\n<p>The Nextcloud package will be downloaded and installed on your server. You can confirm that the installation process was successful by listing the changes associated with the&nbsp;<code><span style=\"font-family: Courier New;\">snap<\/span><\/code>:<\/p>\n<pre class=\"code-pre command\"><code>snap&nbsp;changes&nbsp;nextcloud<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>ID   Status  Spawn                 Ready                 Summary\n2    <span class=\"highlight\">Done<\/span>    2017-10-03T20:03:09Z  2017-10-03T20:03:26Z  <span class=\"highlight\">Install \"nextcloud\" snap<\/span>\n<\/code><\/pre>\n<p>The status and summary indicate that the installation was completed without any problems.<\/p>\n<h3 id=\"getting-additional-information-about-the-nextcloud-snap\">Getting Additional Information About the Nextcloud Snap<\/h3>\n<p>If you&#8217;d like some more information about the Nextcloud&nbsp;<code><span style=\"font-family: Courier New;\">snap<\/span><\/code>, there are a few commands that can be helpful.<\/p>\n<p>The&nbsp;<span style=\"font-family: Courier New;\"><code>snap info<\/code><\/span>&nbsp;command can show you the description, the Nextcloud management commands available, as well as the installed version and the snap channel being tracked:<\/p>\n<pre class=\"code-pre command\"><code>snap&nbsp;info&nbsp;nextcloud<\/code><\/pre>\n<p>Snaps can define interfaces they support, which consist of a slot and plug that, when hooked together, gives the snap access to certain capabilities or levels of access. For instance, snaps that need to act as a network client must have the&nbsp;<span style=\"font-family: Courier New;\"><code>network<\/code><\/span>&nbsp;interface. To see what snap &#8220;interfaces&#8221; this snap defines, type:<\/p>\n<pre class=\"code-pre command\"><code>snap&nbsp;interfaces&nbsp;nextcloud<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>Slot           Plug\n:network       nextcloud\n:network-bind  nextcloud\n-              nextcloud:removable-media\n<\/code><\/pre>\n<p>To learn about all of the specific services and apps that this snap provides, you can take a look at the snap definition file by typing:<\/p>\n<pre class=\"code-pre command\"><code>cat&nbsp;\/snap\/nextcloud\/current\/meta\/snap.yaml<\/code><\/pre>\n<p>This will allow you to see the individual components included within the snap, if you need help with debugging.<\/p>\n<div data-unique=\"configuring-an-administrative-account\"><\/div>\n<h2 id=\"configuring-an-administrative-account\">Configuring an Administrative Account<\/h2>\n<p>There are a few different ways you can configure the Nextcloud snap. In this guide, rather than creating an administrative user through the web interface, we will create one on the command line in order to avoid a small window where the administrator registration page would be accessible to anyone visiting your server&#8217;s IP address or domain name.<\/p>\n<p>To configure Nextcloud with a new administrator account, use the&nbsp;<span style=\"font-family: Courier New;\"><code>nextcloud.manual-install<\/code><\/span>&nbsp;command. You must pass in a username and a password as arguments:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.manual-install&nbsp;Sammy&nbsp;password<\/code><\/pre>\n<p>The following message indicates that Nextcloud has been configured correctly. The first few lines are present because the PCNTL extension is not included with the Nextcloud snap. These can be safely ignored:<\/p>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http:\/\/php.net\/manual\/en\/book.pcntl.php\nNextcloud is not installed - only a limited number of commands are available\n<span class=\"highlight\">Nextcloud was successfully installed<\/span>\n<\/code><\/pre>\n<p>Now that Nextcloud is installed, we need to adjust the trusted domains so that Nextcloud will respond to requests using the server&#8217;s domain name or IP address.<\/p>\n<div data-unique=\"adjusting-the-trusted-domains\"><\/div>\n<h2 id=\"adjusting-the-trusted-domains\">Adjusting the Trusted Domains<\/h2>\n<p>When installing from the command line, Nextcloud restricts the host names that the instance will respond to. By default, the service only responds to requests made to the &#8220;localhost&#8221; hostname. We will be accessing Nextcloud through the server&#8217;s domain name or IP address, so we&#8217;ll need to adjust this setting to accept these type of requests.<\/p>\n<p>You can view the current settings by querying the value of the&nbsp;<span style=\"font-family: Courier New;\"><code>trusted_domains<\/code><\/span>&nbsp;array:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.occ&nbsp;config:system:get&nbsp;trusted_domains<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http:\/\/php.net\/manual\/en\/book.pcntl.php\n<span class=\"highlight\">localhost<\/span>\n<\/code><\/pre>\n<p>Currently, only&nbsp;<span style=\"font-family: Courier New;\"><code>localhost<\/code><\/span>&nbsp;is present as the first value in the array. We can add an entry for our server&#8217;s domain name or IP address by typing:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.occ&nbsp;config:system:set&nbsp;trusted_domains&nbsp;1&nbsp;--value=example.com<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http:\/\/php.net\/manual\/en\/book.pcntl.php\n<span class=\"highlight\">System config value trusted_domains =&gt; 1 set to string example.com<\/span>\n<\/code><\/pre>\n<p>If we query the trusted domains again, we will see that we now have two entries:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.occ&nbsp;config:system:get&nbsp;trusted_domains<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http:\/\/php.net\/manual\/en\/book.pcntl.php\n<span class=\"highlight\">localhost<\/span>\n<span class=\"highlight\">example.com<\/span>\n<\/code><\/pre>\n<p>If you need to add another way of accessing the Nextcloud instance, you can add additional domains or addresses by rerunning the&nbsp;<span style=\"font-family: Courier New;\"><code>config:system:set<\/code><\/span>&nbsp;command with an incremented index number (the &#8220;1&#8221; in the first command) and adjusting the&nbsp;<code><span style=\"font-family: Courier New;\">--value<\/span><\/code>.<\/p>\n<div data-unique=\"securing-the-nextcloud-web-interface-with-ssl\"><\/div>\n<h2 id=\"securing-the-nextcloud-web-interface-with-ssl\">Securing the Nextcloud Web Interface with SSL<\/h2>\n<p>Before we begin using Nextcloud, we need to secure the web interface.<\/p>\n<p>If you have a domain name associated with your Nextcloud server, the Nextcloud snap can help you obtain and configure a trusted SSL certificate from&nbsp;<a href=\"https:\/\/letsencrypt.org\/\">Let&#8217;s Encrypt<\/a>. If your Nextcloud server&nbsp;<em>does not<\/em>&nbsp;have a domain name, Nextcloud can configure a self-signed certificate which will encrypt your web traffic but won&#8217;t be able to verify the identity of your server.<\/p>\n<p>With that in mind, follow the section below that matches your scenario.<\/p>\n<h3 id=\"option-1-setting-up-ssl-with-let-39-s-encrypt\">Option 1: Setting Up SSL with Let&#8217;s Encrypt<\/h3>\n<p>If you have a domain name associated with your Nextcloud server, the best option for securing your web interface is to obtain a Let&#8217;s Encrypt SSL certificate.<\/p>\n<p>Start by opening the ports in the firewall that Let&#8217;s Encrypt uses to validate domain ownership. This will make your Nextcloud login page publicly accessible, but since we already have an administrator account configured, no one will be able to hijack the installation:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;ufw&nbsp;allow&nbsp;80,443\/tcp<\/code><\/pre>\n<p>Next, request a Let&#8217;s Encrypt certificate by typing:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.enable-https&nbsp;lets-encrypt<\/code><\/pre>\n<p>You will first be asked whether your server meets the conditions necessary to request a certificate from the Let&#8217;s Encrypt service:<\/p>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>In order for Let's Encrypt to verify that you actually own the\ndomain(s) for which you're requesting a certificate, there are a\nnumber of requirements of which you need to be aware:\n\n1. In order to register with the Let's Encrypt ACME server, you must\n   agree to the currently-in-effect Subscriber Agreement located\n   here:\n\n       https:\/\/letsencrypt.org\/repository\/\n\n   By continuing to use this tool you agree to these terms. Please\n   cancel now if otherwise.\n\n2. You must have the domain name(s) for which you want certificates\n   pointing at the external IP address of this machine.\n\n3. Both ports 80 and 443 on the external IP address of this machine\n   must point to this machine (e.g. port forwarding might need to be\n   setup on your router).\n\nHave you met these requirements? (y\/n)\n<\/code><\/pre>\n<p>Type&nbsp;<strong>y<\/strong>&nbsp;to continue.<\/p>\n<p>Next, you will be asked to provide an email address to use for recovery operations:<\/p>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>Please enter an email address (for urgent notices or key recovery): <span class=\"highlight\">your_email@domain.com<\/span>\n<\/code><\/pre>\n<p>Finally, enter the domain name associated with your Nextcloud server:<\/p>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>Please enter your domain name(s) (space-separated): <span class=\"highlight\">example.com<\/span>\n<\/code><\/pre>\n<p>Your Let&#8217;s Encrypt certificate will be requested and, provided everything went well, the internal Apache instance will be restarted to immediately implement SSL:<\/p>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>Attempting to obtain certificates... done\nRestarting apache... done\n<\/code><\/pre>\n<p>You can now skip ahead to&nbsp;<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-and-configure-nextcloud-on-ubuntu-16-04#logging-in-to-the-nextcloud-web-interface\">sign into Nextcloud for the first time<\/a>.<\/p>\n<h3 id=\"option-2-setting-up-ssl-with-a-self-signed-certificate\">Option 2: Setting Up SSL with a Self-Signed Certificate<\/h3>\n<p>If your Nextcloud server&nbsp;<em>does not<\/em>&nbsp;have a domain name, you can still secure the web interface by generating a self-signed SSL certificate. This certificate will allow access to the web interface over an encrypted connection, but will be unable to verify the identity of your server, so your browser will likely display a warning.<\/p>\n<p>To generate a self-signed certificate and configure Nextcloud to use it, type:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;nextcloud.enable-https&nbsp;self-signed<\/code><\/pre>\n<div class=\"secondary-code-label \" title=\"Output\">Output<\/div>\n<pre class=\"code-pre \"><code>Generating key and self-signed certificate... done\nRestarting apache... done\n<\/code><\/pre>\n<p>The above output indicates that Nextcloud generated and enabled a self-signed certificate.<\/p>\n<p>Now that the interface is secure, open the web ports in the firewall to allow access to the web interface:<\/p>\n<pre class=\"code-pre command\"><code>sudo&nbsp;ufw&nbsp;allow&nbsp;80,443\/tcp<\/code><\/pre>\n<p>You are now ready to log into Nextcloud for the first time.<\/p>\n<div data-unique=\"logging-in-to-the-nextcloud-web-interface\"><\/div>\n<h2 id=\"logging-in-to-the-nextcloud-web-interface\">Logging in to the Nextcloud Web Interface<\/h2>\n<p>Now that Nextcloud is configured, visit your server&#8217;s domain name or IP address in your web browser:<\/p>\n<pre class=\"code-pre \"><code><span style=\"font-family: Courier New;\">https:\/\/<span class=\"highlight\">example.com<\/span>\n<\/span><\/code><\/pre>\n<p><span class=\"note\"><strong>Note:<\/strong>&nbsp;If you set up a self-signed SSL certificate, your browser may display a warning that the connection is insecure because the server&#8217;s certificate is not signed by a recognized certificate authority. This is expected for self-signed certificates, so feel free to click through the warning to proceed to the site.<br \/>\n<\/span><\/p>\n<p>Since you have already configure an administrator account from the command line, you will be taken to the Nextcloud login page. Enter the credentials you created for the administrative user:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i2.wp.com\/assets.digitalocean.com\/articles\/nextcloud_1604\/login_page.png?w=640&#038;ssl=1\" alt=\"Nextcloud login page\" data-recalc-dims=\"1\"><\/p>\n<p>Click the&nbsp;<strong>Log in<\/strong>&nbsp;button to log in to the Nextcloud web interface.<\/p>\n<p>The first time you enter, a window will be displayed with links to various Nextcloud clients that can be used to interact with and manage your Nextcloud instance:<\/p>\n<p class=\"growable\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i0.wp.com\/assets.digitalocean.com\/articles\/nextcloud_1604\/modal.png?w=640&#038;ssl=1\" alt=\"Nextcloud client modal\" data-recalc-dims=\"1\"><\/p>\n<p>Click through to download any clients you are interested in, or exit out of the window by clicking the&nbsp;<strong>X<\/strong>&nbsp;in the upper-right corner. You will be taken to the main Nextcloud interface, where you can begin to upload and manage files:<\/p>\n<p class=\"growable\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i1.wp.com\/assets.digitalocean.com\/articles\/nextcloud_1604\/main_page.png?w=640&#038;ssl=1\" alt=\"Nextcloud main page\" data-recalc-dims=\"1\"><\/p>\n<p>Your installation is now complete and secured. Feel free to explore the interface to get more familiarity with the features and functionality of your new system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nextcloud, a fork of ownCloud, is a file sharing server that permits you to store your personal content, like documents and pictures, in a centralized location, much like Dropbox. The difference with Nextcloud is that all of its features are open-source. It also returns the control and security of your sensitive data back to you, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":309,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":""},"categories":[4],"tags":[],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/badasscybersecurity.com\/wp-content\/uploads\/2018\/09\/ubuntunextcloud.jpg?fit=327%2C154&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pae4MQ-1N","_links":{"self":[{"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/111"}],"collection":[{"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":2,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions\/310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=\/wp\/v2\/media\/309"}],"wp:attachment":[{"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badasscybersecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}