How to install Nextcloud 13 in FreeNAS with all checks passed updated to use iocage

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
After following the guide verbatim, I receive error message
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Trying to install via vnet it also had me the problem and some but after I installed it most of my problems including this were solved

Code:
iocage create -n nextcloud -r 11.1-RELEASE ip4_addr="vnet0|192.168.1.11/24" defaultrouter="192.168.1.2" vnet="on" allow_raw_sockets="1" boot="on"


Change the IP address and default router to match your setup.
 

oguruma

Patron
Joined
Jan 2, 2016
Messages
226
Trying to install via vnet it also had me the problem and some but after I installed it most of my problems including this were solved

Code:
iocage create -n nextcloud -r 11.1-RELEASE ip4_addr="vnet0|192.168.1.11/24" defaultrouter="192.168.1.2" vnet="on" allow_raw_sockets="1" boot="on"


Change the IP address and default router to match your setup.


That worked. Now the issue I am having is getting certbot to work...

IMPORTANT NOTES:
- The following errors were reported by the server:


To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.


Edit: Sorted that out. I had forced HTTPS redirect before I got the cert....

Now I get a syntax error from my virtualhost file.

SSLCertificateFile takes one argument, SSL Server Certificate file ('/path/to/file' - PEM or DER encoded)
 
Last edited:

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
That worked. Now the issue I am having is getting certbot to work...

IMPORTANT NOTES:
- The following errors were reported by the server:


To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.


Edit: Sorted that out. I had forced HTTPS redirect before I got the cert....

Now I get a syntax error from my virtualhost file.

SSLCertificateFile takes one argument, SSL Server Certificate file ('/path/to/file' - PEM or DER encoded)

I also had the same problem look on page 7-6 in this post you will find the solution
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
Hi I saw a version released 13.0.4 I have 13.0.2 Can I update through the interface itself or should I do something else? Because I want to keep all users and settings as they are
 

dureal99d

Contributor
Joined
Aug 3, 2017
Messages
156
Hi I saw a version released 13.0.4 I have 13.0.2 Can I update through the interface itself or should I do something else? Because I want to keep all users and settings as they are
Yes you can and it should do so pretty seamlessly!!!!
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
Yes you can and it should do so pretty seamlessly!!!!
I think I'm cursed....

I have this error......:(

  • Check for expected files
    The following extra files have been found:
    • .well-known
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
LOL your not cursed. I know it sucks to not have everything working but hang in there... That file is put there when you get the CERTIFICATE. Nextcloud will NOT update unless it can verify every file in the folder. Just delete that file from the Nextcloud folder manually then you can update.
This will be the same for everyone who followed this guide.
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
LOL your not cursed. I know it sucks to not have everything working but hang in there... That file is put there when you get the CERTIFICATE. Nextcloud will NOT update unless it can verify every file in the folder. Just delete that file from the Nextcloud folder manually then you can update.
This will be the same for everyone who followed this guide.
Delete this entire folder?
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
No, just the one file called .well-known

cd /usr/local/www/apache24/data/nextcloud/
rm .well-known
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
No, just the one file called .well-known

cd /usr/local/www/apache24/data/nextcloud/
rm .well-known
For me it's a folder not a single file
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
.well-known is a folder ? Then thats my mistake. But yea remove the whole folder.
rm -r .well-known
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
.well-known is a folder ? Then thats my mistake. But yea remove the whole folder.
rm -r .well-known
The update has started
Let's hope everything goes well
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Good im glad :), hopefully you can sort out your network issues.
 

Itay1778

Patron
Joined
Jan 29, 2018
Messages
269
Good im glad :), hopefully you can sort out your network issues.
Really hope too. I will now try what you told me to try
 

Retrogamer

Dabbler
Joined
Jun 24, 2014
Messages
19
First of all I wanted to thank you very very much!
I have spend hours and hours with guides which tell you to set this up in a pluginjail and every time I ran into unexpected errors which I did not manage to fix.
I also thought about switching my NAS to Ubuntu to get this work, but I really like the stuff Freenas offers.

My Setup: HP N54L with FreeNAS 11.1 and of cause ZFS Raid-Z1.
Now (with the help of this guide) I'm running Nextcloud 13.0.4 in an iocage with php7.2.

I had to change five things which were written in your guide in order to get this work for me.
I wanted to tell you, so maybe you can improve this excellent guide even more.

----------------------------------------------------------------------------------------------------------
Code:
- Create a Jail using iocage

For me vnet="on" did not work as my jail had no internet connection after that.
I tried to fix that by setting ip, gateway and nameserver manually in console, but had no success.
So i did use: iocage create -n "nextcloud" -r 11.1-RELEASE ip4_addr="bge0|192.168.1.3/24" defaultrouter="192.168.1.1" vnet="off" allow_raw_sockets="1" boot="on"
I read that a shared ip setup is even more stable and as this works for me out of the box I use this. 

----------------------------------------------------------------------------------------------------------
Code:
- Download Nextcloud:

I used: wget https://download.nextcloud.com/server/releases/latest.zip
to get the latest Nextcloud release which was 13.0.4 at this time.

----------------------------------------------------------------------------------------------------------
Code:
- Add virtual Host info :

You should say here, that the file should end with a ".conf". At first I only named the file like my domain, without .conf at the end. 
I ran into the error that my https did not work, because the conf file was not loaded beacause the httpd.conf wants to load *.conf files from "Inlcude" only.

----------------------------------------------------------------------------------------------------------
Code:
- Additional steps for php 7.1

Maybe it's because I'm on php7.2 but when i try to change memcache.locale from APCu to Redis I get a server error.
Only when I use it this way it works for me. I have to uncomment locking and use APCu for local (also no error message in Nextcloud)
'memcache.local' => '\\OC\\Memcache\\APCu',
#'memcache.locking' => '\\OC\\Memcache\\Redis',

----------------------------------------------------------------------------------------------------------
Code:
- SSL using Certbot:

Did not work for me at first because in the httpd.conf the webroot wa set to /usr/local/www/apache24/data/, not /usr/local/www/apache24/data/nextcloud.
at first I changes the command to: certbot certonly --webroot -w /usr/local/www/apache24/data/ -d YOURSITE.COM which worked out of the box.
Then I thought this might be not good for autorenewal. So I canged the webroot in the httpd.conf to /usr/local/www/apache24/data/nextcloud and it worked like in the guide.
But maybe this was also an error of the ".conf" Problem not loaded mentioned above. I did this befor renaming the VirtualHost conf file. Think this file also tells where the webroot should be.

Of cause you also mean "nano /usr/local/etc/apache24/httpd.conf" instead of "cd /usr/local/etc/apache24/httpd.conf".

----------------------------------------------------------------------------------------------------------

So all in all minor things that i was able to fix by myself. It tool about 4 hours to install this system completely.
Again, thank you very much for this! This is a very excellent guide!
 

spotcatbug

Dabbler
Joined
Nov 6, 2017
Messages
43
[edit: the below is only true if your certificate was obtained in standalone mode - not sure why mine was]

Just a heads up. After using the OP's guide (thanks OP!), I've been running Nextcloud for, I guess, roughly 70 days. Today I got an email from Let's Encrypt saying that my SSL certificate would expire in 20 days (the Let's Encrypt certs only last 90 days.)

I didn't remember anything about the certificate (70 days is a long time for me to remember something.) However, this seemed really soon to have to be renewing, which got me thinking and then I remembered (miracle!) that the jail had a cron job that was supposed to automatically renew the certificate, so I went looking there.

I found:

* 1 * * 1 /usr/local/bin/certbot renew --quiet

I'm not good at decoding the timing of a crontab entry, but this looks to me like: "Renew the certificate every minute from 1 to 2 AM every Monday." I could very well be wrong about that! It's actually very likely that I am, but...

In any event I decided I would renew right now, rather than wait for the cron job (but, why hadn't it renewed this past Monday? Never mind. Whatever. Move forward.)

I executed the command from the crontab entry: /usr/local/bin/certbot renew and... got an error about binding port 80 - certificate not renewed. Uh oh. After too much Googling (the error message should have been a big enough clue), I realized that you need to stop apache during the renewal. Certbot wants to be sitting on your port 80 while Let's Encrypt does the renewal.

So I've changed my crontab to run a script at 1 AM on the 1st and 15th of every month. The script stops apache, does the renewal and then restarts apache. It's OK to renew more often than every 90 days - if it's more than 30 days until your certificate expires, the renewal just won't happen. I wouldn't do it every hour or anything crazy like that, though.

TL;DR: apache can't be running during the certificate renewal.
 
Last edited:

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
TL;DR: apache can't be running during the certificate renewal.
Then how will your server be able to respond to the certificate request if it's off? The domain validation method that certbot uses requires a valid response from the server for the renewal to take place. If you shut down apache before this happens it can't respond and you won't get a renewal.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Certbot wants to be sitting on your port 80
This is only true if you originally got the cert in standalone mode, which isn't a good idea for exactly this reason.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
"Renew the certificate every minute from 1 to 2 AM every Monday."
Yes, that's what it's saying. No idea why, because that's a silly set of conditions. Much better would be 17 3 * * *, which would run the renew at 3:17 am every day. Pick a time of your choosing, but better if it isn't right on the hour.
 
Top