Nextcloud installed - but how to share files and use https?

When you add a new hard drive, assuming you’re replacing the existing drive with a new drive, you can simply mount it in the same location /media/general/Nextcloud and you won’t have to deal with any of this stuff (just make sure you copy your existing data properly, including timestamps and permissions).
If you get to the point that you need to move the data directory, it is possible, but you’ll probably end up in a thread like this again where you run into multiple hurdles before you are back up and running.

1 Like

Well that didn’t last long… its broke again gggrrrr !!!

When logged into Nextcloud, under the Admin menu it gave me a few security warnings about:

X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN

Using the instructions here…

I edited /etc/apache2/conf-enabled/security.conf so that…

Header set X-Content-Type-Options: NOSNIFF
Header set X-Frame-Options: SAMEORIGIN

… and I restarted the Apache server but I still got the same security warnings in Nextcloud Admin.

Whilst trying to find how to fix this, I noticed that my config /etc/apache2/sites-available/default-ssl.conf was not correct.

ServerAdmin and ServerName were missing so I added these…

ServerAdmin xxxxxxx@xxxxxxx
ServerName xxxxxxxx.dynu.net

The filenames for the SSL certificates were wrong so I corrected them…

SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

And I also uncommented…

BrowserMatch “MSIE [2-6]”
nokeepalive ssl-unclean-shutdown
downgrade-1.0 force-response-1.0

These are the instructions I followed originally as shown in step 33 of my post 26 above to change from HTTP to HTTPS.

I have a feeling that HTTPS was not working correctly because default-ssl.conf was pointing to the default certificates (I cannot remember what they were set to) instead of apache-selfsigned.crt and apache-selfsigned.key.

Since changing the filenames for the certificates I cannot access Nextcloud - I now get the following error:

I was able to access Nextcloud using my IP address 192.1.168.136, but in an attempt to try and fix the issue I rebooted the server and now I my IP address does not work either…

136 2017-12-23 19-24-14

I only uninstalled (deleted) the /var/www/html/nextcloud folder and reinstalled nextcloud, so I assumed the work I did previously to change from HTTP to HTTPS did not need doing again ?

I had installed the Nextcloud client on both my Mac and iPhone and it was all working really well (with the exception of HTTPS possibly?) but since I have done the above changes nothing works. The Nextcloud client on the Mac has lost connection as well.

Did you look at the nextcloud admin guide? It looks like you’ve got some flavor of ubuntu, and the admin guide has a nice step by step guide for ubuntu. It does look like the wrong certs are being used, but my install is CentOS and I’m not really a linux admin. There is a section in the admin guide about it which might help.

The 500 might be related to the other changes you made, check the apache error logs.

As far as the headers, I was getting the same error because my client was getting the two headers twice. They were in the .htaccess file from nextcloud, and also in my apache ssl config. If a browser gets the same header more than once, it’s supposed to ignore the entire header in most cases. When you get the server working again and are back at the admin page, check the headers at the browser end using the browser’s debugger. If the two headers are there two or three times, find all but one of them in the server configs and comment them out.

1 Like

Thanks Scott but I’m now in even more of a mess after trying to fix this.

There are lots of installation guides out there for Nextcloud and using it with HTTPS but not really any uninstallation guides, which is surprising seeing as its difficult if not impossible to change the data folder without re-installing Nextcloud !

It now looks like php is not working and I can’t even enable it even though its installed.

When I put my local IP address (192.168.1.136) into the web browser I get the following:

When I use php -v I get the following:

PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

But when I try to enable it using a2enmod php7 (or php7.0 or php7.022) I get the error…

ERROR: Module php7 does not exist!

… and which php gives me…

/usr/bin/php

I have tried installing php again and again using…

sudo apt-get install lamp-server^
sudo apt-get install libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt
sudo apt-get install php-xml

…but I am still unable to enable it.

Thanks to help from people on this forum I have a 20 step procedure to uninstall Nextcloud, but I get the impression that as I implemented HTTPS there are more steps than this to uninstall Nextcloud which is why I am in the mess I am in ?

If I cant somehow uninstall LAMP then I think the only solution is to re-install Ubuntu all over again, which is crazy when all I wanted to do was change the data path !!!

And if thats the case, for all the effort I might as well just stick with my 3GB Dropbox storage as I didn’t expect it to be anywhere near this complicated.

The specific admin guide I was talking about is Nextcloud’s admin guide which is very complete and it seems to have a step by step for your Linux flavor.

I can confirm the webpage you’re getting means php is not working on the server end, but I think all I had to do was install php. Did you try to just restart the apache server?

I agree that moving the data directory should be easier, but it seems that one of the undocumented assumptions made by the developers was that you were going to do it once and never move it, and now they’ve coded themselves into a corner.

If you just want to start from scratch, there should be a way to make apt remove a program, but I’m not sure, because redhat uses yum. You can try just deleting the entire directory where the webserver lives, but that’s only one step removed from doing a clean linux install :frowning:

1 Like

Thanks Scott, I had a quick look at the Nextcloud admin guide but thats generally for installation and maintenance, nothing in there about uninstallation.

The only reason I am trying to uninstall and reinstall is to change the data path (which I naively thought would be a simple task!) and as I implemented HTTPS to improve security then this appears to make the uninstallation even more complicated which is why I am in the mess I am in now. That leaves me with little alternative but to start all over again and reinstall Ubuntu :frowning: If I go to all that trouble then I dread having to ever change the data path again !!! Alternatively maybe I should just stick with Dropbox, although my storage is limited to 3GB

As a couple of other people have pointed out, the other issue with dropbox is that you have no control of where the data might be located. It could be in China, the EU, the USA, or Russia. It’s just wherever dropbox can find a cheap data center.

I don’t know how experienced you are with Linux admin or IT in general, but if you read over the install guide, you might be able to figure out where you went wrong along the way. The history command defaults to a depth of 1000, I think.

I’m not sure you have to uninstall apache. You just need to uninstall nextcloud. If you’ve got to the point where you’re thinking about doing a full linux reinstall, you can drop your database, delete the directory nextcloud is installed to, and then fiddle with apache separately. All you really need is to serve the simple php info page. Just stick the following line in a test file and make apache serve it to you… If a nicely formatted page comes up, php is working. If not, fix php. Don’t worry about https yet.

<?php phpinfo(); ?>

After php is working, install nextcloud to a new blank directory, then fix https.

1 Like

It sounds like you got your installation into a mess, with making so many changes to Apache config files, installed/uninstalled PHP modules, etc. I would start over, but that’s only because I’m not entirely sure how to reset back to “stock” configurations for Apache and PHP, plus the effort in troubleshooting from where you are is probably going to take a lot more time than starting over completely. I’d say where you went wrong is something with Apache, and that can cause your server to show PHP content as text instead of executing the code even if PHP is installed (which it was, and I assume you hadn’t uninstalled it).
I keep thinking this whole time, why are you following so many different guides from around the internet? The Nextcloud guide is very good, and will walk you through step by step what you need to do for Ubuntu 16.04 including using HTTPS.

This is unfamiliar to me. I’ve never seen these warnings, nor have I manually added this to my Apache config. Currently Nextcloud’s admin page shows no warnings/errors for me. The Nextcloud manual also does not reference either of these things, so that’s pretty interesting to me.

1 Like

Thanks scott and linucksrox

I have only been using Linux for a few months and I’ve used guides and forums like this for help, so I am a beginner. Im sure I’m capable as my job is an embedded software engineer, so Linux is just something new and a learning curve.

I have managed to get my server doing everything I wanted, its just Nextcloud I’ve been struggling with.

Ive setup SSH with keys and on a different port, remote screen sharing, file sharing (SMB), plex media server, time machine (only works with AFP), DNS client, Minecraft server (for my daughter) but Nextcloud has been the most complicated of all to setup !

This is my second attempt at setting up my server but fortunately I kept I record of all the steps this time so the third attempt should be easier.

Having thought about it, I want to change the factory fitted 1TB HDD which the OS runs on for a 4TB WD Red so I will have to do a new install anyway. Hopefully I will get it right the third time !

This time I will use the official Nextcloud installation guide, but it would be nice to know the uninstallation procedure so I don’t have to reinstall my OS again if I ever need to change my data path !

I did manage to uninstall Nextcloud but then somehow Apache / PHP broke, I think maybe because HTTPS confused me?

Welcome to the world of system administration :slight_smile:
The thing is, most of these issues are not specific to Nextcloud. The concept of “uninstalling” Nextcloud doesn’t make much sense because of the nature of how web applications work. There are multiple pieces: the operating system (Ubuntu), web server (Apache), server side language (PHP), database backend (MySQL), and the web application itself (Nextcloud). Uninstalling would consist of deleting the folder/files containing the web application, deleting its database, and removing the entries from the web server. It’s not specifically a Nextcloud thing, it’s a general web application thing. That’s probably why there’s no uninstall guide. You can mix and match many of these components and still end up with a running system, hence the many different conflicting guides out there. I’d say it’s better to follow a single source if possible, especially if you’re not sure what you’re doing.

Or in your case to start over, you should have only needed to start with a fresh Nextcloud folder and new database. When you started changing Apache configs is where things went wrong.

2 Likes