How to Install Nextcloud on Ubuntu

howtonexcloudubuntu

Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud application functionally is similar to Dropbox. Unlike Dropbox, Nextcloud does not offer off-premises file storage hosting. Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices.

To get Nextcloud configured you need a LAMP stack installed on your server, the LAMP stack includes Linux, Apache, Mysql or MariaDB and PHP.

In this guide we'll install Nextcloud on an Ubuntu server running Apache and MariaDB:

Installing LAMP on Ubuntu:

You'll need root (or sudo) access to your server, so let's connect via SSH to the server and then run the following command, which should take care of installing Apache, MariaDB , PHP  and some PHP modules we'll need:

# sudo apt update
# sudo apt-get install apache2 mariadb-server libapache2-mod-php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php-imagick php7.2-xml php7.2-zip -y


nextcloudlampinstall

Once this process is complete we'll go ahead and make sure our MariaDB installation is secure with the following simple command:

# sudo mysql_secure_installation


nextcloud-mysql_secure_installation

Install Nextcloud in Ubuntu:

Once we have a secure database setup we nee to create a database user for Nextcloud, so let's go ahead and log into mysql from the linux shell:

# sudo mysql -u root -p

You'll be prompted to enter the password previously set for mysql. 

MariaDB [(none)]> CREATE DATABASE nextcloud;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> CREATE USER nextcloudadmin@localhost IDENTIFIED BY 'MySuperSecure_#1#$';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.*  TO nextcloudadmin@localhost IDENTIFIED BY 'MySuperSecure_#1#$';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> EXIT;

 

Let's now go ahead and download Nextcloud for installation by going to the Nextcloud download page and then heading over to Download Nextcloud for server, Download Nextcloud which will take us to the zip download page which we'll download using wget from our Ubuntu shell:

# wget https://download.nextcloud.com/server/releases/nextcloud-18.0.1.zip

 

We'll then extract the downloaded file, copy the extracted folder to /var/www/html and change its permissions.

After making sure you have unzip installed (you can do that by running sudo apt install unzip -y) let's go ahead and proceed:


# sudo unzip nextcloud-18.0.1.zip
# sudo cp -r nextcloud /var/www/html/
# sudo chown -R www-data:www-data /var/www/html/nextcloud

 

Configuring Apache2:
With your preferred text editor let's create an Apache virtual server config file, we'll use nano here:

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

Then copy and pase the following code into the nextcloud.conf file we're creating:

Alias /nextcloud "/var/www/html/nextcloud/"
<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
</Directory>

 

Then save and close the file.

Next, let's enable the site we just created and we'll also enable a few apache mods:

# sudo a2ensite nextcloud.conf
# sudo a2enmod rewrite

# sudo a2enmod headers
# sudo a2enmod env
# sudo a2enmod dir
# sudo a2enmod mime




nextcloud-apacheenable

Now we need to restart Apache2 for changes to take effect:

# sudo systemctl restart apache2



We're now ready to complete the setup but from the web browser, so we'll go ahead and access our Nextcloud installation by opening your preferred browser and entering the following in the address bar:

http://your-server-ip/nextcloud 



You will need to enter a few details such as desired admin username and password, we click on Storage & data base to enter the additional details, such as the data folder and the details we previously used to create the database and db user, we can now click on Finish Setup:

nextcloud-initialsetup

 

Once the installation process is complete you'll see the following, just go through the different images providing some information about Nextcloud:

nextcloud-install-complete

And finally on start using Nextcloud:

nextcloud-startusing

 

And here we have it, our own private Nextcloud server, its web interface will look something like this:

nextcloudwebinterface

 

You can check on the Nextcloud manuals (admin and user) to learn how to use it but one of the things I enjoy is being able to sync my files between all my systems (phone and tablets included) while the data is still under my control as it resides on my own server and you can keep it as private as you prefer.


If you'd like to have your own server for this be sure to check out https://owned-networks.net/kvm.html for Cloud server options at great pricing.

  • nextcloud, ubuntu, apache
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

ownCloud Auto Install Script on Debian 7

Here is an easy way to install ownCloud on Debian 7 with a script, but first, for those who...

NGINX – Allow access only to certain IPs

Nginx has a nice module that not many people know about, it basically enables us...

How to configure NTP client in CentOS

What's NTP? NTP stands for Network Time Protocol, and it is an Internet protocol used to...

Initial Server Setup on CentOS 6

Here are some recommendations to setup your VPS or server when you first get it, some of these...

How To Install nginx on CentOS

What is NGINX? Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP,...