Can't install nextcloud behind nginx

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
Hello guys,

I'm really frustrated. I haven't been able to install Nextcloud in weeks (there are many guides out there for Ubuntu, Debian, Apache, etc but not with NC using nginx on FreeBSD) and I don't want to install the plugin since I've read that latest releases do not get pushed to the plugin. Instead of venting, I want to stay positive and say what I have done so far in my attempt to installing NC (I am currently using this guide as reference):
1. I can create the jail just fine
2. I create the users just fine
3. Editing the permissions (from the GUI) is when I have my first issue and is something that I'm not sure I have to do or not since later in the guide, when installing MariaDB we have to make sure the users match (MariaDB creates a user named 'mysql' when installing and I have to match that to the user I create on TrueNAS):
1637455420680.png

4. I can create fstab just fine
5. I can install nginx just fine and start it
6. I can install mariadb104-server and configure it just fine
7. I can install NC with one BIG issue: for some reason, when I unzip the tar file, it will not create the config.php file and I don't know why. I downloaded three different files from here which were latest-21, latest-22, nextcloud-22.2.3
1637455855430.png

and when using the command
Code:
tar -xvf latest-22.tar.bz2
or
Code:
tar -xvf nextcloud-22.2.3.tar.bz2
to see what files were installed, I saw that only these files under the config directory:
1637456080716.png

which makes no sense! (I unzipped all 3 different versions and they all are failing to install config.php. Just to confirm, I downloaded a completely different file on my virtual machine running Ubuntu and it also doesn't install config.php).
8. I can install php80 just fine
9. I can install redis just fine
10. I can create and edit the php.ini just fine (uncomment the necessary commands)

And that is all I'm able to do. I really don't know how to configure NC with my current nginx set up (I have a domain that is currently working for Emby and would like to use a sub domain for NC such as emby.domain.net/nextcloud for example). Is anyone out there with a set up of NC + nginx + FreeBSD + MariaDB that can help me with this please?
 

vidx

Dabbler
Joined
Oct 16, 2021
Messages
40
I installed Nextcloud using the official plugin fuss free and I could always update to the latest patch without problem. Just saying...
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
And even when not using the plugin why on earth don't you use the FreeBSD package? pkg install nextcloud-php74
Second, why do you need a matching mysql user on TrueNAS? Users and groups inside the jail are completely independent from anything happening on the NAS host system.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Good shout about staying positive and not venting, as it would at yourself!

As others have suggested, there are various ways of installing Nextcloud these days, but when I first did it manually I used this guide > https://www.truenas.com/community/threads/how-to-owncloud-using-nginx-php-fpm-and-mysql.17786/

It's from 2014 and installs ownCloud, but the principles are pretty much the same for NextCloud and you'd need to update the package details anyway. I still think it's one of the best guides and helped me to build my knowledge of how all this works back in the day.

This one is a little more up to date, but looks pretty good > https://www.truenas.com/community/t...-an-iocage-jail-with-hardened-security.72016/

You're probably also going to need a jail to do some reverse-proxying if you plan to make this and other services available over the internet. Here's a link to a guide for that by the same guy > https://www.truenas.com/community/r...rse-proxy-with-ssl-termination-in-a-jail.132/

What you're trying to do is very much possible as I have Nextcloud, emby and a handful of other things running from my FreeNAS server. Good luck and stay positive :smile:

ps: I think you just
Code:
cp config.sample.php config.php
and then edit as required.
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
I installed Nextcloud using the official plugin fuss free and I could always update to the latest patch without problem. Just saying...
Huh. Interesting. Wouldn't hurt to try it then.

And even when not using the plugin why on earth don't you use the FreeBSD package? pkg install nextcloud-php74
Second, why do you need a matching mysql user on TrueNAS? Users and groups inside the jail are completely independent from anything happening on the NAS host system.
I didn't know about this package/command. Let me try it out!

Good shout about staying positive and not venting, as it would at yourself!

As others have suggested, there are various ways of installing Nextcloud these days, but when I first did it manually I used this guide > https://www.truenas.com/community/threads/how-to-owncloud-using-nginx-php-fpm-and-mysql.17786/

It's from 2014 and installs ownCloud, but the principles are pretty much the same for NextCloud and you'd need to update the package details anyway. I still think it's one of the best guides and helped me to build my knowledge of how all this works back in the day.

This one is a little more up to date, but looks pretty good > https://www.truenas.com/community/t...-an-iocage-jail-with-hardened-security.72016/

You're probably also going to need a jail to do some reverse-proxying if you plan to make this and other services available over the internet. Here's a link to a guide for that by the same guy > https://www.truenas.com/community/r...rse-proxy-with-ssl-termination-in-a-jail.132/

What you're trying to do is very much possible as I have Nextcloud, emby and a handful of other things running from my FreeNAS server. Good luck and stay positive :smile:

ps: I think you just
Code:
cp config.sample.php config.php
and then edit as required.
I have read both posts from Samuel (I'm using them as reference to do the installation but he uses Apache and I have nginx) and some of the stuff is a bit over my head. Also, this is exactly my intention, to gain knowledge. I'll read the first link you provided along with the other suggestions by Vidx and Patrick, then I'll post back!
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
Hello @Patrick M. Hausen, I wanted to ask you about that command you provided me... doing some research, I found this page and when installing NC, the config.php file generated was the bare minimum. My understanding is that when NC gets installed, the config.php should be similar to this:
1637615565174.png

where there is an 'instanceid' assigned. This is the issue I'm still having and is why I don't just copy config.example.php into config.php because the instanceid along with password and other variables are missing. By doing pkg install nextcloud-php74 the config.php generated does not have the 'instanceid' populated. Instead, I get this as a config.php:
1637616313850.png

I can certainly edit this file but what about the instanceid?

This is the part that does not happen for me (from NC documentation):

1637615937141.png

Is there a step maybe that I am missing?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
IIRC the config file will get populated by the web install wizard.
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
This is where I am right now after typing the IP of the jail on my browser:
1637623292441.png


Is this because I'm missing the config.php? Also, this might be a silly question but after I execute tar -xvf latest-22.tar.bz2 /usr/local/www/ how do I actually install nextcloud? I found this on the documentation:
1637639500716.png

but since I am not on Linux, I don't know what command to use to actually install NC.
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Extracting the tarball is installation in web applications like Nextcloud. But IMHO you should really use the FreeBSD package instead.
You need to configure your Nginx webserver for Nextcloud, so instead of the default page the Nextcloud start page is shown. A complete well documented example can be found here:

You will need to adjust some things of course, e.g. root /var/www/nextcloud; will need to be changed to root /usr/local/www/nextcloud; or whatever you intend to use. That would be the correct path for the package.

Also you will need to install php-fpm. And possibly adjust some settings there, too.

As for the installation instructions - they do not say to use chown www-data ... they say to use the web server runtime user and www-data is just an example that works on some but not all Linux distributions.
The correct user is www on FreeBSD. But if you use the package, that is already taken care of. That's why YOU SHOULD USE THE PACKAGE.

I will attach my /usr/local/etc/nginx/include/nextcloud.conf and my /usr/local/etc/php-fpm.d/www.conf - you will need to change at least the server name in the Nginx configuration for your own hostname. And remove the .txt extension from the filenames. Also this file runs Nextcloud with HTTP only (no HTTPS), because I use a reverse proxy for all HTTPS termination and certificate management.

But you should be able to start from there.

As I have repeatedly stated on this forum, Nextcloud is a complex modern web application built from many parts and installation and safe operation requires familiarity with at least:
  • web server administration
  • database server administration
  • PHP
The documentation is written for people who know Nginx. And know MySQL/MariaDB ... Sorry, that's just a fact.

Another question you asked: yes, the absence of a config file tells Nextcloud to launch the installation wizard at first connect with a browser, if I am not mistaken. This is a common pattern for web applications.

HTH,
Patrick
 

Attachments

  • www.conf.txt
    19.4 KB · Views: 213
  • nextcloud.conf.txt
    5.7 KB · Views: 192

vidx

Dabbler
Joined
Oct 16, 2021
Messages
40
If anyone is interested, this was the video I followed. Easy to setup Nextcloud with reverse proxy and it works flawlessly.

 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
I did use the package after the tar ball was not working for me. Is only later that I realized I needed to do sudo -u www php occ maintenance:install --database instead of sudo -u www-data php occ maintenance:install --database. After that, Nextcloud installed without issues.

I have also relied on the nginx documentation you are providing. Thank you for the files provided, I'll see what the difference is and update accordingly.

Also @vidx, the first thing I did when I asked for help was to install the plug-in (works only locally) and give access to my family members... they needed to upload pictures/videos to offload their phones :smile:
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
Update:
I was able to finally install NC using pkg install nextcloud-php74 . I edited config.php to add the trusted domains as well as updating my nginx.conf (my reversed proxy) using the documentation as a reference. If I type the IP/nextcloud/ on the browser I get this:
1637704878600.png


This is my nginx.conf:
- deleted the pics -

And this is my config.php:
1637705455335.png


As you can see, I'm trying this out first on a temporal jail because I'm learning how the process works. I guess now is about configuring nginx with NC. I also compared the files you sent me @Patrick M. Hausen and they are about the same. How do I debug this?
 

Attachments

  • 1637705051702.png
    1637705051702.png
    201.7 KB · Views: 165
  • 1637705708427.png
    1637705708427.png
    71.3 KB · Views: 166
  • 1637706129347.png
    1637706129347.png
    105.1 KB · Views: 176
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
First, please copy and paste the text output and don't use screenshots. Use code tags like so:
Code:
This is
in code
tags


Second, you cannot use an IP address - you absolutely must use a host name to access your Nextcloud. For starters while you are in your LAN and don't have anything opened to "the Internet" yet - you might want to add a static entry to /etc/hosts (Mac OS, Linux, BSD) or C:\SYSTEM32\DRIVERS\ETC\HOSTS (Windows) like e.g. 192.168.1.5 nextcloud.mydomain.lan

As for your current problem - please repost the config files, error message, everything ... as text. I definitely cannot work with graphics.

HTH,
Patrick
 

vidx

Dabbler
Joined
Oct 16, 2021
Messages
40
Also @vidx, the first thing I did when I asked for help was to install the plug-in (works only locally) and give access to my family members... they needed to upload pictures/videos to offload their phones

I'm not sure about others but when I installed the Nextcloud plugin, https was automatically enabled by nginx with a self-signed cert for local access.

Capture.JPG


The settings were in /usr/local/etc/nginx/conf.d/nextcloud.conf

Code:
# Redirect to HTTPS
server {
    listen 80 default_server;
    listen [::]:80;

    location ^~ /.well-known/acme-challenge {
        # Path to the root of your installation
        root /usr/local/www/nextcloud/;
        try_files $uri $uri/ =404;
    }

    location / {
       return 301 https://$host:8283$request_uri;
    }
}



It works for me on my local network as well as on DDNS with the reverse proxy. If you are accessing locally, the steps for reverse proxy could be skipped.

You have made progress with your manual install but if you ever decide to go the easy route, the plugin is not as bad as some say it is.
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
Hello @Patrick M. Hausen, these are the files in .txt format. I can provide other ones as well.
Thank you for the help!
 

Attachments

  • nginx.conf.txt
    7.7 KB · Views: 179
  • config.php.txt
    969 bytes · Views: 158

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Why are you configuring Nginx as a reverse proxy? I thought you have a single jail and are trying to get a Nextcloud installation up and running?
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
To have a picture of what I have or am trying to do:
Jail 1: nginx
Jail 2: Emby
Jail 3: Nextcloud

All the internet traffic is being handle by nginx (as well as certificates) and I'm trying to simply add to the nginx.conf file the proxy settings for Nextcloud in order to send/receive files over the internet. I currently have the proxy settings for Emby working just fine.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
But you do have another Nginx running in your Nextcloud jail, right? Nextcloud won't work without a local web server. You can use the config file I posted for that one and test if Nextcloud works, first, before moving to the reverse proxy.
 

Meya

Dabbler
Joined
Dec 5, 2018
Messages
39
But you do have another Nginx running in your Nextcloud jail, right? Nextcloud won't work without a local web server. You can use the config file I posted for that one and test if Nextcloud works, first, before moving to the reverse proxy.
Correct, NC has its own nginx server inside the jail. Let me test the config file inside the jail then.

Update: Is your nextcloud.conf.txt exactly how you have it inside your nextcloud's jail? (nginx.conf). I'm asking because usually the "server" or "upstream" directive are inside the http blocks. As a result, I'm getting errors when restarting nginx.
 
Last edited:
Top