In today’s world, data is your most important asset but how you manage it is another challenge. We store our data on different devices but it is not safe and convenient when you have to retrieve some useful documents or pictures. Here comes the use of NextCloud, which makes it easier for you to store and manage your data in your personal workplace, whether it’s on your home or office system. Nextcloud is an open-source solution that protects your data and offers you access from your system of mobile devices where you have the options to sync, access, or share data.
In this article, we are going to show you the Nextcloud installation setup on a home system running Ubuntu 20.04 LTS operating system (OS). You can opt to use other Linux distributions as well, but Ubuntu is one of the most useful operating systems.
Prerequisites:
The prerequisites for the Nextcloud setup are to have a running LAMP stack on your Ubuntu system.
Follow the steps below to complete the prerequisites by installing the LAMP stack using Apache Web server and MySQL Database.
Step 1: Installation of LAMP (Linux Apache MySQL PHP)
Every web-based application like Nextcloud is dependent on the LAMP stack. LAMP stack is an installation of Linux open-source tools, comprising of Web servers and Database servers.
Let’s run the command below to install the Apache Web Server and MySQL Database server along with PHP and its other required dependencies.
1 |
# apt-get install apache2 mysql-server php php-mysql php-gd php-json php-curl php-mbstring libapache2-mod-php php-intl php-imagick php-xml php-zip php-mysql php-bcmath php-gmp zip |
Type ‘Y’ for yes to continue the installation.
Step 2: Configure Database for Nextcloud
Once the installation is complete, make sure that the service of Apache Web and MySQL Database is up and running. Next, at the very first step, use the below command to secure the Database by setting its root password, removing anonymous users as shown below.
Run the commands below to create a new user and database to be used for the Nextcloud setup.
1 2 3 4 5 6 7 |
mysql> create database nxc_db; mysql> create user 'nxcuser'@'localhost' identified by 'Hidaya@123'; mysql> grant all privileges on nxc_db.* to 'nxcuser'@'localhost'; mysql> FLUSH PRIVILEGES; |
We have created the DB user and password. Now exit the DB console using the “exit” command.
1 |
mysql> exit; |
Now we have a LAMP ready to perform the installation of the Nextcloud setup on it. Let’s move to the next step to download and install Nextcloud.
Step 3: Downloading Nextcloud setup
The latest Nextcloud installation setup can be downloaded from the official web link of Nextcloud, where you can download its Mobile, Desktop, and Server version.
We are going to get its latest server version from their website as shown.
1 |
# wget <a href="https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip" target="_blank" rel="noopener noreferrer">https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip</a> |
When you have downloaded the installation package, extract it into the document root directory of your web server which is ‘/var/www/html/’
1 |
# unzip nextcloud-21.0.1.zip -d /var/www/html/ |
After extracting the archive, change ownership and permissions of the extracted directory to www-data using the below command.
1 2 3 |
# chown -R www-data:www-data /var/www/html/nextcloud # chmod -R 775 /var/www/html/nextcloud |
Step 4: Configure Web Server for Nextcloud
After downloading and extracting the setup files into the web document root directory, we are going to configure the Apache webserver to serve the contents of Nextcloud.
Let’s create a new conf file and add the following virtual host entry to that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# vim /etc/apache2/sites-available/nxcweb.conf <VirtualHost *:80> DocumentRoot "/var/www/html/nextcloud" ServerName nxcweb.test.com ErrorLog ${APACHE_LOG_DIR}/nxcweb.error CustomLog ${APACHE_LOG_DIR}/nxcweb.access combined <Directory /var/www/html/nextcloud/> Require all granted Options FollowSymlinks MultiViews AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud Satisfy Any </Directory> </VirtualHost> |
Save and close the file using your editor and run the below command to enable the new virtual host and its other required modules in your web server.
1 2 3 4 5 |
# a2ensite nxcweb.conf # systemctl reload apache2 # a2enmod rewrite headers env dir mime setenvif ssl |
Make sure to reboot the webserver service after making these changes as indicated.
1 |
# systemctl restart apache2 |
Step 5: Completing Nextcloud Web Setup
At this step, we will complete the Nextcloud web setup by accessing its web interface using the server name we have defined in its Virtual Host configuration setup.
Let’s open up your web browser and access your domain.
Fill in the required information for your Admin account, give the Database credentials you have set up earlier, check with install recommended apps and click to Finish setup as shown.
Step 6: Using Nextcloud Dashboard
We have Nextcloud setup installed, configured, and running on our home setup test domain.
You can make use of the recommended apps that we have installed during the setup. In order to download and install a new application, just drop down your account and click the App button to enable new applications as shown below.
Now let’s see how you can make use of it in your daily routine by uploading your valuable contents.
Click on the Files icon on the top left bar to upload your documents using the ‘Plus’ icon.
Conclusion:
In this article, we have thoroughly covered the steps to set up a NextCloud productivity platform on our self-hosted home system. We have also covered the detailed steps to prepare the LAMP stack as a prereq. Now, following this article you can make use of this tool in your daily routine by setting it up in your home or office premises. Making use of this tool, you can manage your data in one safe place and access it from remote devices.