Update the repositories, install Apache, MySQL and Unzip
#Update the repositoriessudoaptupdate#Install apache2sudoaptinstallapache2#Install mysql-serversudoaptinstallmysql-server#Install unzip (will be needed later)sudoaptinstallunzip
Secure MySQL database
#Secure the mysql-server repositoriessudomysql_secure_installationVALIDATEPASSWORDCOMPONENT:nNewrootpasswort:<YOURMYSQLPASSWORD>Re-enternewpassword:<YOURMYSQLPASSWORD>Removeanonymoususer:yDisallowrootloginremotely:yRemovetestdatabaseandaccesstoit:yReloadprivilegestablesnow:y
Prepare MySQL database for Nextcloud
#Accessing the mysql-shell as rootsudomysql-uroot-p<YOUR MYSQL PASSWORD>#If you enter the mysql-shell as root, execute the following sql-commandsmysql> createdatabasenextcloud;mysql> createuser'nextcloud'@'localhost'identifiedby'PASSWORD';mysql> grantallprivilegesonnextcloud.*to'nextcloud'@'localhost';mysql> flushprivileges;mysql> quit
Install PHP for Nextcloud
#For nextcloud to work, install the latest version of PHP and a few PHP librariessudoaptinstallphp7.4sudoaptinstallphp7.4-gdphp7.4-mysqlphp7.4-curlphp7.4-mbstringsudoaptinstallphp7.4-intlphp7.4-gmpphp7.4-bcmathphp7.4-xmlsudoaptinstalllibapache2-mod-php7.4php7.4-zipphp-imagickphp-apcu
Download Nextcloud Hub 21 (on the following website)
#Download the latest version of Nextcloud directly on your serverwgethttps://download.nextcloud.com/server/releases/nextcloud-21.0.0.zip#Unzip the nextcloud-zip-file into the www directory of Apachesudounzipnextcloud-21.0.0.zip-d/var/www#Switch to the directory of Apachecd/var/www#Change ownership of the nextcloud-folder to Apache (which is the "www-data" user)sudochown-Rwww-data:www-datanextcloud/
Configure Apache for Nextcloud
#Enable a few Apache modifications for Nextcloudsudoa2enmodheadersenvdirmimerewrite#Restart apache2sudoserviceapache2restart
Now, I am here
#Switch to the directory of the default Apache configurationcd/etc/apache2/sites-available#Open the 000-default.conf-file with nano to edit itsudonano000-default.conf#File: /etc/apache2/sites-available/000-default.conf<VirtualHost *:80>DocumentRoot/var/www/nextcloudServerName10.100.1.179<Directory/var/www/nextcloud/>RequireallgrantedAllowOverrideAllOptionsFollowSymLinksMultiViews<IfModulemod_dav.c>Davoff</IfModule></Directory>ErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.logcombined</VirtualHost>
#Restart apache2 againsudoserviceapache2restart#Enter the following command to show the local ip address of the server hostname-I|awk'{print $1}'
Nextcloud configuration
It's important to set up a static local ip address for your server, which you can do in your router's configuration:
#Switch the directory to the config.php file cd/var/www/nextcloud/config#If there is no file create a new file called: config.php with the following commandsudonanoconfig.php
#Edit the content of the config.php file<?php$CONFIG = array ('trusted_domains' =>array (0 =>'10.100.1.179',#ip address of your server and/or domainname ), );
#Change owner of the config.php filesudochownwww-data:rootconfig.php#Change the authorization of the config.php filesudochmod777config.php