How to install Nextcloud in Ubuntu

Installation of NextCloud in Ubuntu

NextCloud is a free source cloud software that permits your server to act as a cloud based storage unit for the clients. Installation of NextCloud in Ubuntu is explained in this article.

To install NextCloud in Ubuntu

Setup a LAMP Server to start with the NextCoud installation, run the following command to setup the LAMP server.

root@linuxhelp:~# apt-get install lamp-server^ -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting ' libhttp-message-perl'  for task ' lamp-server' 
Note, selecting ' libencode-locale-perl'  for task ' lamp-server' 
Note, selecting ' php7.0-cli'  for task ' lamp-server' 
Note, selecting ' mysql-client-5.7'  for task ' lamp-server' 
Note, selecting ' libapache2-mod-php'  for task ' lamp-server' 
Note, selecting ' rename'  for task ' lamp-server' 
Note, selecting ' mysql-server-5.7'  for task ' lamp-server' 
Note, selecting ' php-common'  for task ' lamp-server' 
Note, selecting ' libaprutil1'  for task ' lamp-server' 
Note, selecting ' mysql-server'  for task ' lamp-server' 
.
.
.


Next install the necessary PHP extensions.

root@linuxhelp:~# apt-get install php-gd php-json php-mysql php-curl php-intl php-mcrypt php-imagick php-zip php-dom php7.0-xml php-mbstring -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting ' php7.0-xml'  instead of ' php-dom' 
php-mysql is already the newest version (1:7.0+35ubuntu6).
The following packages were automatically installed and are no longer required:
  libpango1.0-0 libpangox-1.0-0 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-21-generic linux-image-extra-4.4.0-21-generic
Use ' sudo apt autoremove'  to remove them.
The following additional packages will be installed:
  libmcrypt4 libzip4 php7.0-curl php7.0-gd php7.0-intl php7.0-mbstring php7.0-mcrypt php7.0-zip ttf-dejavu-core
.
.
.
Creating config file /etc/php/7.0/mods-available/xml.ini with new version

Creating config file /etc/php/7.0/mods-available/xmlreader.ini with new version

Creating config file /etc/php/7.0/mods-available/xmlwriter.ini with new version

Creating config file /etc/php/7.0/mods-available/xsl.ini with new version
Setting up ttf-dejavu-core (2.35-1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.3) ...


Then edit the php.ini file as shown below.

root@linuxhelp:~# vim /etc/php/7.0/apache2/php.ini 

Change the value for the parameters as shown below.

[...]

memory_limit = 512M
date.timezone = Asia/Kolkata
upload_max_filesize = 200M
post_max_size = 200M

[...]


After changing the values, restart the apache service by running the following command.

root@linuxhelp:~# systemctl restart apache2 


Then login to mysql database and create database for NextCloud.

root@linuxhelp:~# mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with   or g.
Your MySQL connection id is 4
Server version: 5.7.15-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.

mysql>  CREATE DATABASE cloud_db 
Query OK, 1 row affected (0.03 sec)

mysql>  GRANT ALL PRIVILEGES ON cloud_db.* TO ' cloud_user' @' localhost'  IDENTIFIED BY ' 123'  
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql>  flush privileges 
Query OK, 0 rows affected (0.06 sec)

mysql>  exit
Bye


Next download the package for NextCloud, move to the document root and execute the below command.

root@linuxhelp:~# cd /var/www/html/
root@linuxhelp:/var/www/html# wget https://download.nextcloud.com/server/releases/nextcloud-10.0.0.zip 
--2016-10-11 04:38:39--  https://download.nextcloud.com/server/releases/nextcloud-10.0.0.zip
Resolving download.nextcloud.com (download.nextcloud.com)... 88.198.160.133
Connecting to download.nextcloud.com (download.nextcloud.com)|88.198.160.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 46895219 (45M) [application/zip]
Saving to: ‘ nextcloud-10.0.0.zip’ 

nextcloud-10.0.0.zip                        100%[========================================================================================> ]  44.72M   671KB/s    in 2m 10s  

2016-10-11 04:40:50 (352 KB/s) - ‘ nextcloud-10.0.0.zip’  saved [46895219/46895219]


Once the download is completed, unzip the package.

root@linuxhelp:/var/www/html# unzip nextcloud-10.0.0.zip  
Archive:  nextcloud-10.0.0.zip
   creating: nextcloud/
   creating: nextcloud/ocs/
  inflating: nextcloud/ocs/routes.php  
  inflating: nextcloud/ocs/v2.php    
  inflating: nextcloud/ocs/v1.php    
  inflating: nextcloud/ocs/providers.php  
  inflating: nextcloud/console.php   
   creating: nextcloud/ocs-provider/
  inflating: nextcloud/ocs-provider/index.php  
  inflating: nextcloud/version.php   
   creating: nextcloud/core/
.
.
.
inflating: nextcloud/apps/files_videoplayer/appinfo/app.php  
  inflating: nextcloud/apps/files_videoplayer/appinfo/signature.json  
   creating: nextcloud/resources/
   creating: nextcloud/resources/config/
  inflating: nextcloud/resources/config/mimetypemapping.dist.json  
  inflating: nextcloud/resources/config/ca-bundle.crt  
  inflating: nextcloud/resources/config/mimetypealiases.dist.json  
   creating: nextcloud/resources/codesigning/
  inflating: nextcloud/resources/codesigning/root.crt  
  inflating: nextcloud/resources/codesigning/core.crt  
  inflating: nextcloud/resources/codesigning/owncloud.crt


Change the ownership for the NextCloud directory.

root@linuxhelp:/var/www/html# chown -R www-data:www-data nextcloud 


Create virtualhost for NextCloud. Use the following command to create the new apache configuration file for virutalhost.

root@linuxhelp:/var/www/html# vim /etc/apache2/sites-available/nextcloud.conf 
Entry:
Alias /nextcloud " /var/www/html/nextcloud/" 
  Options +FollowSymlinks
  AllowOverride All

 
  Dav off

 SetEnv HOME /var/www/html/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud

Now enable the following apache modules by running the following command.

root@linuxhelp:/var/www/html# a2enmod rewrite 
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart
root@linuxhelp:/var/www/html# a2enmod headers 
Enabling module headers.
To activate the new configuration, you need to run:
  service apache2 restart
root@linuxhelp:/var/www/html# a2enmod env 
Module env already enabled
root@linuxhelp:/var/www/html# a2enmod dir 
Module dir already enabled
root@linuxhelp:/var/www/html# a2enmod mime 
Module mime already enabled


Then restart the Apache services.

root@linuxhelp:/var/www/html# systemctl restart apache2 


Lets continue the installation from web browser. Open the link http://< IP_address> /nextcloud/

Fill the details regarding admin account and database synchronization.

FAQ
Q
Why is my md5sum of the image file different than the md5sum on the site?
A
The md5sum on the site is the md5sum of the tar.bz2 file that you get after you download, not the image's one.
Q
I have been updating through nc-update but why isn't Nextcloud on the latest version?
A
nc-update only updates NextCloudPi related stuff. In order to upgrade the Nextcloud instance itself you use nc-update-nextcloud.
Q
Post Only Your Own Stuff
A
You may not post anything digital that belongs to someone else without permission. You may not post descriptions of, links to, or methods for stealing someone’s intellectual property (softwar
Q
What is NextCloudPi?
A
NextCloudPi is a ready to use image for Raspberry Pi that runs NextCloud software to enable your Pi to be a home cloud server. This code also generates the NextCloudPi ARM docker image.
Q
Do I have to configure every entry in the WebUI and the TUI?
A
No. You only need to run the Wizard to have a working Nextcloud instance. Everything else is optional.