How to Install NextCloud 14 on Ubuntu 16.04
In order to run NextCloud on your system, the following requirements have to be met:
- MySQL or MariaDB
- PHP 7.0 +
- Apache 2.4 with mod_php module
In this tutorial, we will show you how to install NextCloud 14 with Apache web server, PHP and MySQL database server on an Ubuntu 16.04 system.
Step 1: Log in via SSH and Update your System
First, you will need to log in to your Ubuntu 16.04 system via SSH as the root user:
ssh root@IP_ADDRESS -p PORT_NUMBER
and as usual, run the following commands to upgrade all installed packages on your system:
apt-get update apt-get upgrade
Step 2: Install Apache
Installing Apache is pretty simple – it can easily be installed by using the apt-get package manager:
apt-get install apache2
After the installation is completed, you can then enable the Apache web server to start automatically upon server reboot:
systemctl enable apache2
You can verify if the Apache server is running by executing the following command:
systemctl status apache2
Or, you can check if the web server is successfully installed and running by navigating to http://your_server_IP using your web browser of choice. If everything is OK your browser will load the default Apache webpage.
Step 3: Install PHP 7.0
To install PHP 7 and some PHP modules required by NextCloud, run the following command:
apt-get install php7.0 libapache2-mod-php7.0 php7.0-intl php7.0-gd php7.0-json php7.0-mysql php7.0-common php7.0-curl php7.0-mbstring php7.0-mcrypt php7.0-xml php-imagick php7.0-zip
Step 4: Install MySQL and Create a Database
Next, we will install the MySQL server. To do this, simply run the following command:
apt-get install mysql-server
You can now start the database server and enable it to automatically start upon boot, with the following commands:
systemctl start mysql systemctl enable mysql
You can also run the mysql_secure_installation script to harden the security of your MySQL database server:
After you have answered all of the questions, you can now go ahead and log in to MySQL as the root user by using the password we entered in the previous step:
mysql -u root -p
To create a new database for your NextCloud installation, run the following commands:
CREATE DATABASE nextcloud_db; GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'PASSWORD'; FLUSH PRIVILEGES; exit;
Don’t forget to replace ‘PASSWORD’ with an actual strong password.
Step 5: Install NextCloud 14
Our hosting environment is ready, and additionally, we have created a new database. We can now proceed with the actual installation of NextCloud.
Run the following commands to download and extract the latest NextCloud 14 installation files:
cd /var/www wget https://download.nextcloud.com/server/releases/latest-14.zip unzip latest-14.zip chown -R www-data:www-data nextcloud rm latest-14.zip
Step 6: Create the Apache Virtual Host File
If you want to be able to access NextCloud with a domain name, you will have to create a new virtual host. You can do this with the nano text editor:
Now enter the following information into the file:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/nextcloud ServerName your-domain.com ServerAlias www.your-domain.com Alias /nextcloud "/var/www/nextcloud/" <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory> ErrorLog /var/log/apache2/nextcloud-error_log CustomLog /var/log/apache2/nextcloud-access_log common </VirtualHost>
Then we need to enable the virtual host file with the following command:
ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
Also, we need to make sure that the following apache mods are also enabled:
a2enmod rewrite headers env dir mime
Finally, restart the Apache web server:
systemctl restart apache2
Step 7: Complete the NextCloud Installation via Web Browser
You can now go to your http://your-domain.com (or http://YOUR_IP_ADDRESS) and follow the on-screen instructions to complete the NextCloud installation.
You will need to create your admin user account by choosing your own username and password. Under the “Storage & Database” section, enter the information of the database we have previously created and then click on “Finish Setup”.
That’s it. Your NextCloud has been successfully installed and you can log in with the login credentials of your admin user.