Today we will show you how to install Nextcloud on Ubuntu 16.04, using Apache web-server and MySQL database.
Nextcloud is open source self-hosted file sync and share application forked from ownCloud. It has a lot of extra Calendar, Sync and Contacts features, apart from their file hosting features and it is a great free alternative to some popular services such as Google Drive, Dropbox, Box, etc.
It is fairly easy to install Nextcloud on an Ubuntu 16.04 VPS. The installation process should take about 5-10 minutes if you follow the very easy steps described below.
At the time of writing this tutorial, Nextcloud 12.0.0 is the latest stable version available and it requires:
– Apache web server;
– PHP (5.6 or higher) along with the mbstring, curl, zip, xml, tidy, gd and mcrypt extensions. They are most generally active by default on a standard php installation.
– MySQL(version 5.5 or higher) installed on your Linux VPS;
1. Getting Started
First of all login to your Ubuntu 16.04 VPS via SSH as user root
At the very beginning, it is best to start a screen session by executing the following command
screen -U -S nextcloud
Update the system:
apt-get update && apt-get -y upgrade
Make sure to always keep your server up to date.
2. Install MariaDB 10.0
To install MariaDB, run the following command:
apt-get install -y mariadb-server
Next, we need to create a database for our Nextcloud installation.
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE nextcloud; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'your-password'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
Do not forget to replace ‘your-password’ with a strong password.
3. Install Apache2 web server
[user]$ sudo apt-get install apache2
4. Install PHP and required PHP modules
To install the latest stable version of PHP version 7 and all necessary modules, run:
[user]$ sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-bcmath php7.0-xml php7.0-json php7.0-tidy
5. Configure Apache Web Server
Enable the Apache2 rewrite module if it is not already done:
[user]$ sudo a2enmod rewrite
6. Restart Apache Web Server
In order to activate the new configuration, restart the Apache web server using the following command:
[user]$ sudo service apache2 restart
7. Download and Extract Nextcloud
Download and extract the latest version of Nextcloud on your server:
[user]$ sudo cd /opt && wget wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip [user]$ sudo unzip nextcloud-12.0.0.zip [user]$ sudo mv nextcloud/ /var/www/html/
8. Configure File Ownership
All files have to be readable by the web server, so we need to set a proper ownership
[user]$ sudo chown www-data:www-data -R /var/www/html/nextcloud/
9. Create Virtual Host in Apache
Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘nextcloud.conf’ on your virtual server:
[user]$ sudo touch /etc/apache2/sites-available/nextcloud.conf [user]$ sudo ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf [user]$ sudo nano /etc/apache2/sites-available/nextcloud.conf
Then, add the following lines:
<VirtualHost *:80> ServerAdmin email@example.com 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>
10. Restart Apache Web Server
Restart the Apache web server for the changes to take effect:
[user]$ sudo service apache2 restart
11. Complete the Nextcloud Installation via Web Browser
Open your favorite web browser, navigate to http://your-domain.com/ and if you configured everything correctly the Nextcloud installer should be starting. You should follow the easy instructions on the install screen inserting the necessary information as requested.
That is it. The Nextcloud installation on Ubuntu 16.04, is now complete.
Of course, you don’t have to install Nextcloud 12 on Ubuntu 16.04, if you use one of our Software Installation Services, in which case you can simply ask our expert Linux admins to install Nextcloud 12 on Ubuntu 16.04, for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on how to install Nextcloud 12 on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.