In this tutorial we are going to learn how to install Nextcloud on Ubuntu 18.04. We will also install and configure its prerequisites. 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. NextCloud provides user friendly web interface, so you can easily access your files through web browser from public and private network or from any device.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Nextcloud on Ubuntu 18.04
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y apt-get upgrade -y
Step 2. Installing LAMP on Ubuntu 18.04.
You should check out this LAMP stack install tutorial for Ubuntu 18.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that NextCloud relies on:
apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
Step 3. Installing NextCloud on Ubuntu 18.04 Bionic Beaver.
NextCloud offers you the zipped archives for server admins to download and manually set it up on top of LAMP:
wget https://download.nextcloud.com/server/releases/latest.tar.bz2 tar -jxvf latest.tar.bz2 sudo mv nextcloud /var/www/html/ sudo mkdir /var/www/html/nextcloud/data
Next, give proper permission to NextCloud directory:
sudo chown -R www-data:www-data /var/www/html/nextcloud/
Step 4. Configure Database for NextCloud.
Next, we need to create a database for the Nextcloud installation:
mysql -uroot -p
Run the following command to create a database for NextCloud:
MariaDB [(none)]> CREATE DATABASE nextcloud; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'strong_password'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
Step 5. Configure Apache for NextCloud.
Next, you will need to create a virtual host file for NextCloud:
Add the following lines:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot "/var/www/html/nextcloud/" ServerName your-domain.com ServerAlias www.your-domain.com <Directory "/var/www/html/nextcloud/"> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/your-domain.com-error_log CustomLog /var/log/apache2/your-domain.com-access_log common </VirtualHost>
Once done it’s time to enable the new site and enable Apache mods that are needed by NextCloud:
a2ensite nextcloud a2enmod rewrite headers env dir mime systemctl restart apache2
Step 6. Accessing NextCloud Web Installation.
Now you can access the Nextcloud web install wizard in your browser by entering the domain name or http://your-ip-address to continue your Nextcloud installation.
Congratulation’s! You have successfully install and configured Nextcloud on your Ubuntu 18.04 server. Thanks for using this tutorial installing Nextcloud open source file synchronization and sharing solution on Ubuntu 18.04 LTS (Bionic Beaver) system.