NextCloud is a free and open source file sharing application like Dropbox. You can securely share files, folders, documents, emails, contacts, bookmarks and appointments using NextCloud. 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.
It is fully open source, but it charges fee for support. NextCloud also allows you to share your files with other users, to create password protected links, to allows other users to upload files to your cloud.
In this tutorial, we will see how to install and use NextCloud on Ubuntu 16.04 server.
##Prerequisites
- A server running Ubuntu 16.04.
- A non-root user with sudo privileges setup on your server.
- A static IP address 192.168.15.110 configure on your server.
Update the System
First, update your system to the latest stable version by running the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Once your system is up to date, you can proceed to the next step.
Install LAMP Stack
Before starting, you will need to install Apache, MariaDB, PHP7 and other required PHP modules on your system.
You can install them by running the following command:
sudo apt-get install apache2 mariadb-server php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-json php7.0-intl php7.0-imagick php7.0-xml php7.0-mbstring php7.0-zip php7.0-gd php7.0-mysql php7.0-curl php7.0-mcrypt
Once installation is complete, start apache and mariadb service and enable them to start at boot with the following command:
sudo systemctl start apache2
sudo systemctl start mysql
sudo systemctl enable apache2
sudo systemctl enable mysql
Next, you will need to tweak some php settings in order to make Nextcloud work properly. You can do this by editing php.ini
file:
sudo nano /etc/php/7.0/apache2/php.ini
Change the following values:
memory_limit = 1000M
date.timezone = Asia/Kolkata
upload_max_filesize = 200M
post_max_size = 200M
Save and close the file when you are finished, then you can proceed to the next step.
Configure Database for NextCloud
By default MariaDB installation is not secured, so you will need to secure it first.
You can secure it by running the mysql_secure_installation
script.
sudo mysql_secure_installation
Answer all the questions as shown below:
Enter current password for root (enter for none):
Change the root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Next, login to MariaDB console and create a database for the NextCloud:
mysql -u root -p
Enter your MariaDB root password and hit enter. Once you are logged in to your database, you need to create a database for NextCloud:
Run the following command to create a database for NextCloud:
MariaDB [(none)]> CREATE DATABASE nextclouddb;
Next, create a new database user and provide the appropriate privileges to your database user over the database you have created.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouddb'@'localhost' IDENTIFIED BY 'password';
Next, run the following command to immediately apply the changes on the database privileges:
MariaDB [(none)]> FLUSH PRIVILEGES;
Next, exit from the Mysql with the following command:
MariaDB [(none)]> \q
Install NextCloud
You can download the latest version of the NextCloud from the URL https://download.nextcloud.com/server/releases/
.
Otherwise run the following command to download it using terminal:
wget https://download.nextcloud.com/server/releases/nextcloud-11.0.0.zip
Once download is complete, unzip the downloaded file with the following command:
unzip nextcloud-11.0.0.zip
Next, copy extracted directory to your apache web root directory:
sudo cp -ar nextcloud /var/www/html/
Next, give proper permission to nextcloud directory:
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud
Configure Apache for NextCloud
Next, you will need to create a virtual host file for NextCloud inside /etc/apache2/sites-available/
directory:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following lines:
<VirtualHost *:80>
DocumentRoot "/var/www/html/nextcloud"
ServerName 192.168.15.110
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
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>
Save and close the file when you are finished, then enable virtual host with the following command:
sudo a2ensite nextcloud.conf
sudo systemctl restart apache2
You will also need to enable some apache modules:
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod mime
sudo a2enmod dir
Finally, restart Apache service to take effect the changes:
sudo systemctl restart apache2
Accessing NextCloud Web Installation Wizard
Before accessing NextCloud, you will need to allow port 80
through UFW firewall.
By default UFW is disabled on your system, so you need to enable it first.
You can enable it with the following command:
sudo ufw enable
Once UFW firewall is enabled, you can allow port 80
by running the following command:
sudo ufw allow
80`
You can now check the status of UFW firewall by running the following command:
sudo ufw status
Once firewall is configured, open your web browser and type the URL http://192.168.15.110. You should see the admin account creation page.
Fill in all the details as shown below:
Username : nextcloudadmin
Password : nextcloud@123
Data folder : /var/www/html/nextcloud/data
Database user : nextcloud
Database password : password
Database name : nextclouddb
Once you have finished, click on the Finish setup
button to sign into Nextcloud.
Conclusion
Congratulations! You have successfully installed NextCloud on your Ubuntu 16.04 server. You can now easily play around with NextCloud, and also deploy it on your production environment. You can also explore the interface and for additional functionality by installing plugins using Nextcloud’s app store.