From 39f4f8a531e66ce4536ac0b119228edeab1ee9a1 Mon Sep 17 00:00:00 2001 From: CoogyEoin <> Date: Wed, 30 Jun 2021 18:27:52 +0000 Subject: Adding Nextcloud --- nextcloud.html | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 nextcloud.html diff --git a/nextcloud.html b/nextcloud.html new file mode 100644 index 0000000..ac73997 --- /dev/null +++ b/nextcloud.html @@ -0,0 +1,224 @@ + + + + Nextcloud Server – LandChad.net + + + + + + + +

Nextcloud Server

+ +
+ +

Nextcloud is by far the best (and in many ways only) free and open source cloud storage solution. Not only can the client be used on nearly all platforms such as desktop, android and IOS but it also doesn't take up much memory on your server. +

+ +

You'll need a server or VPS running a Debian-based OS (Ubuntu 20 or Debian 10 are recommended) and at least 512MB of RAM. You'll also need a domain name pointing to your server's IP address. +

+ +

+ Note that although you can use NGINX instead of Apache (and I've successfully done it before) it's not officially supported. + More info here. +

+ +

Automatic Installation

+

If you want to just automatically do all the steps below then you can use my installation script + in my git repo linked here. + Or alternatively you can use the Nextcloud installation wizard in the official documentation but I've found before that it fails if you don't have a certain amount of memory allocated. +

+ +

Manual Installation

+ +

Setting up Apache and Mariadb

+ +

+First thing we'll need to do is install the dependancies. We'll be using Mariadb and Apache for the server. Simply run the below command. +

+ +
apt install apache2 software-properties-common mariadb-server php7.3 libapache2-mod-php7.3 php7.3-mysql
+ +

+Enable and start the apache systemD service with the below command: +

+ +
systemctl start apache2
+systemctl enable apache2
+
+ +

+Next run the mysql_secure_installation using the below command +

+ +

+mysql_secure_installation
+
+ +

+Next run mariadb and enter the below SQL commands. +

+ +

+CREATE DATABASE nextcloud;
+CREATE USER nextcloud IDENTIFIED BY 'ENTER A SECURE PASSWORD';
+GRANT USAGE ON *.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'YOUR PASSWORD';
+GRANT ALL privileges ON nextcloud.* TO 'nextcloud'@'localhost';
+FLUSH PRIVILEGES;	
+
+ + + +

Installing the Nextcloud Application

+ +

+First we'll install some more dependancies. +

+ +

+apt install php7.3-gd php7.3-json php7.3-mysql php7.3-curl php7.3-mbstring php7.3-intl php7.3-imagick php7.3-xml php7.3-zip
+
+ +

+Next we'll install the nextcloud app and move the relevant files to your apache server directory. +

+ +

+wget https://download.nextcloud.com/server/releases/nextcloud-15.0.7.tar.bz2
+tar -xvf nextcloud-15.0.7.tar.bz2
+cd nextcloud
+mkdir /var/www/nextcloud/
+
+mv ./* /var/www/nextcloud | mv ./.htaccess /var/www/nextcloud | mv ./.user.ini /var/www/nextcloud
+
+ +

+Next we'll remove this installed directory and change the permissions. +

+ +

+cd /var/www/nextcloud
+rm -r ~/nextcloud/
+chown -R www-data:www-data ./*
+chown www-data:www-data .htaccess
+chown www-data:www-data .user.ini
+
+ + +

Setting Up Encryption (SSL)

+ +

+Next we'll create an SSL certificate for your domain name. For tutorial purposes I'll use the domain nextcloud.example.com. Thanks to the EFF anyone can get an SSL certificate for free using Certbot. +First we'll install the dependancies: +

+ +

+apt install certbot python3-certbot-apache
+
+ +

+Next you'll need to go to the file /etc/apache2/sites-available/000-default.conf and change the section in ServerName from example.com to whatever your domain is. +Then you can copy this file to the sites enabled with the below commands: +

+

+cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf
+systemctl restart apache2
+
+ +

+Next run the below command to create your cert: +

+ +

+certbot --apache -d $my_domain --redirect
+
+ +

Housekeeping and security best practices

+

+The remaining commands are just to make your server work/secure it as much as possible. +First we'll need to create the directory for storing the data. We're doing it in the root directory so there's no chance of someone accessing it from the browser. +

+ +

+mkdir /nextcloud-data
+chown www-data:www-data /nextcloud-data
+chown www-data:www-data /nextcloud-data/
+
+ +

+Next go to the /etc/php/7.3/apache2/php.ini and make the following changes. +

+ +

+Change upload_max_filesize = 2M to 512M +

+

Change memory_limit = 128M to 512M +

+

Change post_max_size = 8M to 512M +

+ +

+Next go to the /etc/apache2/sites-enabled/000-default-le-ssl.conf file and add the following to it: +NOTE: Remove the space at the start of the IfModule and VirtualHost tags I only added it in because html makes it disappear. +

+ +

+
+< IfModule mod_ssl.c>
+< VirtualHost *:443>
+        ServerName $my_domain
+        
+          Header always set Strict-Transport-Security \"max-age=15552000; includeSubDomains; preload\"
+        
+	
+		Options +FollowSymlinks
+		AllowOverride All
+	
+        ServerAdmin webmaster@localhost
+        DocumentRoot /var/www/nextcloud
+        ErrorLog ${APACHE_LOG_DIR}/error.log
+        CustomLog ${APACHE_LOG_DIR}/access.log combined
+ServerAlias $my_domain
+SSLCertificateFile /etc/letsencrypt/live/$my_domain/fullchain.pem
+SSLCertificateKeyFile /etc/letsencrypt/live/$my_domain/privkey.pem
+Include /etc/letsencrypt/options-ssl-apache.conf
+< /VirtualHost>
+< /IfModule>
+
+
+ +

+Then run the below commands and you should be all set: +

+ +

+systemctl restart apache2
+a2enmod headers
+
+-u www-data php /var/www/html/./occ db:convert-filecache-bigint
+
+ + +

+If you run into any issues then feel free to checkout the documentation or send me an email or message. My details are below. +

+ +

+My Website: https://biasedriot.co +

+ +

+My Youtube Channel: https://www.youtube.com/channel/UCehh50T6qtDpt_kEUF33GJw +

+ +

+Monero: 84Y4FZiTbLeR5qc1fBrBhB1yq5agKtEdoixq2w1ysXJv486MiBCz3czGT15bqeXDPpdLoNyF93inxY3BCk6g8mrDMNKoArS +

+

+Bitcoin: 1Dmn9jEtWAhdLk1HHWkUVNeDdAaBCwNajm +

+
+ + + -- cgit v1.2.3