In this post, we will setup a server and install Nextcloud on it. My distribution of choice is Ubuntu Server, version 16.04 LTS. I happen to like the non-GUI interface, so everything will be done in the terminal. I will make this as short as possible. Let’s start!
The server has 1 virtual processor and 1 GB of memory. More than enough for a home test server running Nextcloud. Use the default settings during install. At the end, when asked about packages to add, choose these three:
When asked, set a password for MySQL root user and remember it.
After installation, update the server:
sudo apt update
sudo apt upgrade
There is a good idea to set up a static IP for the server. Open and edit this file:
sudo nano /etc/network/interfaces
iface [your adapter name] inet dhcp
iface [your adapter name] inet static
address 192.168.1.10 (or whatever IP you wish to assign to it)
gateway 192.168.1.1 (the address of your router)
Save and close the file with Ctrl-O and Ctrl-X. Reboot the server to reflect the changes.
Next, we are going to create a MySQL database for Nextcloud:
sudo mysql -u root -p
create database nextcloud;
GRANT ALL ON nextcloud.* TO ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘password’;
Choose your own database name, user and password. We will need them later.
A good practice is to secure the mysql installation. Run this command:
Answer no the the first two questions and yes to the rest.
Next, we need to install a set of php modules needed by Nextcloud:
sudo apt-get install php-gd php-json php-curl php-mbstring
sudo apt-get install php-intl php-mcrypt php-imagick php-xml php-zip
Also, enable two additional Apache mods and restart Apache to make them available:
sudo a2enmod rewrite headers
sudo service apache2 restart
We are ready now to download and install Nextcloud. We will use the following commands:
sudo wget https://download.nextcloud.com/server/releases/latest-13.tar.bz2
sudo tar -jxvf latest-13.tar.bz2
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo rm latest-13.tar.bz2
All done in the command line. Reboot the server and then open the IP address in a browser, like this:
192.168.1.10/nextcloud (or whatever IP you assigned to it earlier)
You will see the initial configuration for Nextcloud.
Create a user and a password in the first window and enter the database details in the second one. Leave the Data folder as is. Click on Finish setup.