Skip to content
SDI-Docs

Install NextCloud

First you need to install mariadb and configure it by executing following commands

apt update
apt -y install mariadb-server mariadb-client
mysql_secure_installation

Make sure a password is required to access MySQL via the command line

mysql -u root
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Then create the nextcloud database

mysql -u root -p
CREATE USER 'benni@locahost' IDENTIFIED BY 'password';
CREATE DATABASE nextcloud;
GRANT ALL ON nextcloud.* to 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloud';
FLUSH PRIVILEDGES;
QUIT

Now Install PHP and Apache. In this case Apache is already installed.

apt -y install php php-{cli,xml,zip,curl,gd,cgi,mysql,mbstring}
apt -y install apache2 libapache2-mod-php

Add PHP variables in /etc/php/*/apache2/php.ini

date.timezone = Europe/Berlin
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300

Now Restart Apache

systemctl restart apache2

Now Download nextcloud

apt -y install curl unzip
curl -o nextcloud-22.zip https://download.nextcloud.com/server/releases/latest-22.zip
unzip nextcloud-22.zip
mv nextcloud /var/www/
chown -R www-data:root /var/www/nextcloud
chmod -R 755 /var/www/nextcloud

Now add the NextCloud Folder in to our apache config under /etc/apache2/mods-available/alias.conf

Alias /nextcloud "/var/www/nextcloud/"

<Directory "/var/www/nextcloud/">
    Require all granted
    AllowOverride None
    Options Indexes Multiviews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
</Directory>

Now create a new VirtualHost by adding this to /etc/apache2/sites-enabled/mk381.conf

<VirtualHost *:80>
	ServerAdmin [email protected]
	DocumentRoot /var/www/nextcloud
	ServerName mi.hdm-stuttgart.de
	ServerAlias nextcloud.mi.hdm-stuttgart.de
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now Restart Apache

systemctl restart apache2

Now you can open http://sdi01a.mi.hdm-stuttgart.de/nextcloud/index.php in your browser

And configure your nextcloud installation like this.

In our case the config for the db is username: nextcloud, password: nextcloud, database: nextcloud

Next-cloud-install

After that you click on install and wait for the redirect

Next-cloud-installed