Basically, Nextcloud is a self-hosted DropBox. Here's a simple guide on how to install it on an Ubuntu machine. For a more detailed explanation, check the official Nextcloud installation guide.
The following command install the packages required to run Nextcloud:
sudo apt-get install php-mysql php-curl php-json php-mcrypt php-intl php-imagick php-gd php-zip php-xml php-mbstring
Nextcloud uses a database engine to keep track of files activity. There are multiple options for database engines but here I use MariaDB. A user and database must be created for Nextlcoud to use. This can be done with as so:
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'username'@'localhost' IDENTIFIED BY 'password';
Here, username and password must be replaced with whatever you choose. With this example, the database is named nextcloud.
The following Apaches must be enabled using the a2enmod command:
An Apache site must be enabled to handle requests for Nextcloud. An example Apache config file is available on the Nextcloud manual installation guide.
Once the above is done, Nextcloud can be downloaded, extracted and placed in the apache site directory (/var/www/). It is important not to forget to give ownership to the nextcloud folder to the www-data user.