How to install NextCloud on Ubuntu 16

Try it in our public cloud & Get $50 Credit
CLAIM NOW

NextCloud is a platform for collaboratively sharing files, documents, calendars and contacts between devices and individuals. With NextCloud installed, you can replace Dropbox and Google services with those you host yourself, respecting the autonomy and privacy of your data. NextCloud works with all major operating systems and mobile platforms. As a fork of Owncloud, it is compatible with all Owncloud-based sync clients, and also integrates with standard calendar and email protocols. In this guide, we’ll be installing NextCloud on an Ubuntu 16.04 LTS server.

Getting Started

To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 16.
• All commands should be run as the root user
• A LAMP stack using Nginx, PHP and MariaDB

Tutorial

Begin by updating your package cache. You’ll also need the unzip package, which isn’t a standard utility in Ubuntu’s default installation.

apt-get update
apt-get install unzip -y

NextCloud requires a few additional PHP modules not included in the typical LAMP stack. We’ll install those next.

apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-zip php7.0-dom php7.0-xml -y

Fetch the NextCloud archive into your document root, then uncompress the archive.

wget https://download.nextcloud.com/server/releases/nextcloud-9.0.53.zip
unzip nextcloud-9.0.53.zip
mv nextcloud/ /var/www/html/

You can always find the latest NextCloud version at http://nextcloud.com/install/.

Apache will need to create and update files in the NextCloud directory in order to synchronize them between devices. Here we’ll set up the correct access permissions.

chown -R www-data. /var/www/html/nextcloud

NextCloud also needs a database and database user to keep its data. Create the necessary database and credentials:

mysql -u root -p

CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'nextcloudpassword';
FLUSH PRIVILEGES;
EXIT

With the new modules installed, Apache will need to be restarted so newly-launched PHP processes can use them.

systemctl restart apache2.service

The remaining steps are performed in NextCloud’s online installer. Visit http://your_ip/nextcloud/ to continue.

Create your initial NextCloud user. Not only will this user be able to sync files, contacts, calendars and email, but it will also have administrative privileges on the server.

You’ll also need to enter the database name and credentials as set up previously.

Conclusion

NextCloud is now running, and ready to synchronize data among all your devices. Continue by installing NextCloud’s file synchronization clients, and by integrating its calendar and contacts feeds into your email client of choice. Once you’ve got things working, be sure to share this article to help free others from proprietary cloud-based services.