This article breaks the installation and configuration of the NextCloud into 4 parts, and shows you the path to your own private cloud storage. These 4 parts are:
- NextCloud tarball installation
- DB server
- Apache / Nginx server
Though this guide is Ubuntu-titled, all is applicable to other Linux distributions but the package management with
According to the official document, for Ubuntu server user, we can type the commands below to fetch and install the PHP modules supporting the core NextCloud server hosting.
# apt-get install apache2 mariadb-server libapache2-mod-php7.2
And if you need some PHP extensions, you should also install the
libapache2-mod-php7.2. For more information, please refer to here.
Up to the day the note is finished, the latest tarball available can be downloaded through this link.
After validations, unzip it and move it to the document root of your web server. For example:
# unzip nextcloud-188.8.131.52.zip -d nextCloudInstall
Let take mariaDB for an example.
Its installation is quite straightforward:
Add the MariaDB signing key:
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
Download and execute the script to set up the mariadb apt repository:
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
Update your sources list:
apt install mariadb-server
On finishing the installation, a prompt of setting the primary password is supposed to pop up. But under some special circumstances, it won’t. So you are not able to login into the server. To solve this, you can try either reinstalling the
mariadb-server or solution below:
- Restart the service in
# systemctl restart mariadb && mysql_safe --skip-grant-tables &
- Update your password
or if you encounter non-updatable warning, try followings:
Then you can log in with password
'' now. It’s recommended that you reset a stronger password rather than
Make sure that you can log into the mysql as root before doing followings.
CREATE USER 'nextcloud'@'localhost' identified by 'StrongPassword';
After that, set the transcation isolation level to avoid problems. Also it’s recommended to set the
(If not present, you can just create the file and add these lines.)
Since I am using mariadb, which is an fork of mysqldb, there are other configurations necessary under
/etc/php/7.2/apache2/conf.d/mysql.ini. Configuration below activates the connection between mariadb and apache, where option
mysql.default_socket are crucial :
# configuration for PHP MySQL module
On Debian, Ubuntu, and their derivatives, Apache installs with a useful configuration so all you have to do is create a
/etc/apache2/sites-available/nextcloud.conf file with these lines in it, replacing the Directory and other filepaths with your own filepaths:
Alias /nextcloud "/var/www/nextcloud/"
Then enable the newly created site:
# a2ensite nextcloud.conf.
Also, you should enable the module
# a2enmod rewrite
Other recommended modules are:
# a2enmod headers
You must disable any server-configured authentication for Nextcloud, as it uses Basic authenticationi internally for DAV services. Following the above example configuration file, add the following line in the
After all above, renable the apache server:
# a2enmod rewrite dir mime env headers
Now your site is reachable. Note that the firewall might block outer connections.
If you get Internal Server Error at your first access to the site. Find some information from
For example, if you found
chmod() related error. You may solve it with
# chown -R www-data:www-data /var/www/html && chown -R www-data:www-data /var/www/nextcloud