[How-To] ownCloud using NGINX, PHP-FPM, and MySQL

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
I got an error Code 1
make config-recursive install -C /usr/ports/databases/pecl-redis
make config-recursive install -C /usr/ports/devel/pecl-APCu
Dat LE I was able to create a script to install nextcloud with SSL from letsencrypt and nginx per this thread forked from @danb35 script that uses apache. I've been unable to figure out why that error occurs. In order to get everything working I had to move the su -m www -c 'php /usr/local/www/nextcloud/occ config:system:set memcache.locking --value="\OC\Memcache\Redis"' to the bottom after the other commands are executed. I don't know if the order of items in the config.php make any difference but it seems to work. Hope you find it helpful.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Hi, has anyone tried this in Freenas 11.1 and/or in an iocage jail?

I've just setup Nextcloud 13.0.2 in a 11.1-U4 iocage jail following this guide. Still one of the best IMHO ;)
 

kwessel

Dabbler
Joined
Mar 30, 2015
Messages
44
Upgrade issues:

I have had two Owncloud boxes per this guide running rock solid for three years. Recently my Owncloud desktop client indicated I needed to upgrade my server.

I used the cyberjock’s instructions ( https://forums.freenas.org/index.ph...nx-php-fpm-and-mysql.17786/page-3#post-106402 ) for the upgrade (which I had done before) and lost access to the Owncloud server.

My first problem happened when I tried to fetch the new version. I got an error: “No Address Record.” Probably unwisely, I downloaded the owncloud-9.0.11.tar.bz2 file with a browser and then put it in the tmp directory using SFTP. Upon running it I got an error message and have tried numerous things to get Owncloud running again without success.

I will post a screen shot of the error after attempting to run the upgrade.

Any suggestions?
 

kwessel

Dabbler
Joined
Mar 30, 2015
Messages
44
upload_2018-11-14_13-11-3.png
 

kwessel

Dabbler
Joined
Mar 30, 2015
Messages
44
I have nearly 5tb of photos on this system now, so I would like to get it going for now. I have another machine and will try building something in iocage.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,449
I have nearly 5tb of photos on this system now, so I would like to get it going for now. I have another machine and will try building something in iocage.

This is a bit tricky but there should be no showstopper:

I am in a similar situation as my server is also pointing to the "owncloud" folder, at least this is what I see from your low resolution picture, but I have since long been performing updated to maintain the "owncloud" folder structure. My latest update is Nextcloud 13.0.7.

There are several aspect of the migration using iocage which is by far preferable but the first thing you need to know is the details about your "nginx" and "Mysql".

I would use Danb35 script to Nextcloud as the base of you install:

First of all, make sure you have snapshots of your "db" and "files" dataset as a precaution. At least if you have your "files" dataset available, all the files you have from the various user account will be accessible there if you mount them as SMB or browse through over SSH, but it is not what you should do here.

If you have snapshots of the old jail, I would clone the snapshots that are from the time just before the update as it contains information within your "Nginx" account profile.

If it was running on iocage, which it doesn't you could have reverted the jail before updrage without too much trouble.

If you were to follow danb35 script, you will need information related to your MySQL database which are store into your jail somewhere like:

/usr/local/www/owncloud/config

The file containing the info is "config.php".
The element you need to save are:

'passwordsalt'
'secret'
'dbname'
'dbuser'
'dbpassword'
'instanceid'
'htaccess.RewriteBase'

If you do a fresh install by script, the above elements are going to be automaticaly created and you will need to have them match the one you recovered.

Without those, you will not be able to connect to the database because it is encrypted.

Then you will have to worry about PHP and how it handles access to Nextcloud.
For that two scenario:

1) you want to retain your "domain.xyz/owncloud" so your current users can access there own account as if nothing changed, you can use the scipt unmodifie ( almost umodifed ) and you will need to implement a "RewriteRule" within your "VirtualHost" section of your "domain.xyz.conf" file hosted by Apache24.
I was successful going this far, but the issue that remain unresolved on my end is RewriteRule command to support Windows and Android App redirection. As of now I am unable to have them connect to the server with existing link.

2) if the scenario above is not an option, you need to modify a few of the danb35 script to change the default
Code:
DocumentRoot "/usr/local/www/apache24/data/nextcloud"

into something like this:

Code:
DocumentRoot "/usr/local/www/apache24/data/cloud"


The script requires to have "db", "files" and "portsnap" dataset created. You should group them under one dataset of your choice which doesn't contain anything.
Upon running the script, after it has been clones from git and created your nextclou-config file, you will have Freenas create and mount the iocage jail you named in your nextcloud-config file.
Information on how to access the newly created Nextcloud server will be provided with the credential. You need to access it to see if the installation was successful.
At that point, if you can access Nextcloud, you are only accessing the MySQL data from the new installed Nextcloud.

To access you old data, you will need to stop the iocage jail you just created in order to edit the "fstab" file.
This is easily done using "ssh" to your Freenas box and use "nano" or "mc" to edit it in the iocage section. You can also do it with Freenas web GUI for "jails".

The "fstab" or mount point need to be chnaged to point to yu old "db" and "files" dataset locations.

Restart jail and after a few seconds you should have access to the new Nextcloud with the old data, but there will be updates Nextcloud will need to perform.
With Nextcloud 14, I am not able to update the database due to some unknown errors.
Instead of installing the latest 14 tar file, I would suggest you stick with the latest 13 tar file instead.
You just need to edit the script to point to the 13 install file location instead.

If you still need the "/owncloud/" folder as part of your domain, you will also need to update the script which include the "occ" relevant commends as they are hard coded.
Not a bit thing, but it has to be done properly.

Letsencrypt can be tricky at first and is one thing that will cause to not being able to access Nextcloud, but if certificate issueance is successful you will be much closer to sorting this issue out.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,449
I have nearly 5tb of photos on this system now, so I would like to get it going for now. I have another machine and will try building something in iocage.
If you can replicate your entire volume to a second machine, that would be the way to go until you get through the migration.
 
Joined
Dec 2, 2015
Messages
730
Upgrade issues:

I have had two Owncloud boxes per this guide running rock solid for three years. Recently my Owncloud desktop client indicated I needed to upgrade my server.

I used the cyberjock’s instructions ( https://forums.freenas.org/index.ph...nx-php-fpm-and-mysql.17786/page-3#post-106402 ) for the upgrade (which I had done before) and lost access to the Owncloud server.

My first problem happened when I tried to fetch the new version. I got an error: “No Address Record.” Probably unwisely, I downloaded the owncloud-9.0.11.tar.bz2 file with a browser and then put it in the tmp directory using SFTP. Upon running it I got an error message and have tried numerous things to get Owncloud running again without success.

I will post a screen shot of the error after attempting to run the upgrade.

Any suggestions?
Do you have any automatic snapshots you might be able to use to rollback the failed update attempt? My automatic snapshots have saved my butt more than once when an upgrade attempt went sideways.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,449
Do you have any automatic snapshots you might be able to use to rollback the failed update attempt? My automatic snapshots have saved my butt more than once when an upgrade attempt went sideways.
If Owncloud install based on this post is followed correctly, and it has been a while since I have used it, there should be a step where a backup of the Owncloud server itself has been created.

It seems, under the "files" dataset exist backups for each new updates that have been preformed.

Location can be something like:

Code:
/files/updater-"someinstancedID string"/backups


I would assume, backing up the current one and then copying the relevent folder might do the trick.
 

PrincePaul

Patron
Joined
Feb 26, 2012
Messages
225
@Joshua Parker Ruehlig:
Awesome how to - worked like a charm on 11.2!
Thanks a lot for the effort ;)

Atm the only thing for me is getting letsencrypt to work plus the http to https redirect is always pointing at cloud.example.com - even though the nginx config seems to be fine. I´ll figure that out later....
 
Last edited:

JyothishC

Cadet
Joined
Mar 14, 2019
Messages
2
anyone having this problem when tiring in install an app in owncloud:

This app cannot be installed because the following dependencies are not fulfilled:

The library openssl is not available. The library ldap is not available.
Hi I have this error. Did you figure out?
 

thefox13

Dabbler
Joined
Sep 15, 2014
Messages
21
Remember if you upgrade a previous owncloud install to 10.3 to update your cronjob commands to:

*/15 * * * * /usr/local/bin/php -f /usr/local/www/owncloud/occ system:cron
 

frank_drebin

Cadet
Joined
Jan 23, 2020
Messages
3
@Joshua Parker Ruehlig Thank you for the effort! Owncloud is working fine for several years now. I have been thinking about reinstalling owncloud in a new jail, because to my knowledge it is not possible to update a jail and a reinstall is cleaner anyway. Nevertheless, I don't really understand how to migrate the owncloud database. I read somewhere that you can't simply copy it, but you have to dump it with some owncloud commands. So why did you set up a database storage outside of the jail in the first place? For the data folder it makes sense to me somehow, because of the snapshots, but if the database is bound to the jail anyway, I could simply snapshot both together or am I missing something? What is the best way, to set up owncloud with an existing database?
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,449
@frank_drebin , What I have always done is start as if creating a entirely new owncloud/nextcloud environment, such as new jail, db, files, portsnap and install dataset. Ideally, you want to install the same version of owncloud/nextcloud you are currently using and make sure it works by default.
Once it is working, you will need to update the mount points of the new iocage jail to point to your own db and files datasets.
You will need to update the content of the config.php located under the owncloud/nextcloud "settings" folder with the details related to database credentials. Those should be the same than the one on your old setup.

By doing so, you should now have access to your data.

Only then should you think about upgrading Owncloud/Nextcloud.
 

frank_drebin

Cadet
Joined
Jan 23, 2020
Messages
3
@Apollo Thank you for your answer. I set up an entirely new owncloud environment including the database, but unfortunately the mysql-server does not start properly after changing the mount points to the old file and db directories. Although I updated the credentials in config.php and ran service mysql-server start, mysql still does not run and trying to access the database results in ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2). Do you have an idea what I did wrong? In previous posts you suggested not to set up a new database, but to skip this part and just to set the correct mount points. What is the better way? Sorry I am a little bit confused.
In addition, during the step with mysql_secure_installation I selected "Switch to unix_socket authentication [Y/n]" -> "n". Could this be the problem?
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,449
@Apollo Thank you for your answer. I set up an entirely new owncloud environment including the database, but unfortunately the mysql-server does not start properly after changing the mount points to the old file and db directories. Although I updated the credentials in config.php and ran service mysql-server start, mysql still does not run and trying to access the database results in ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2). Do you have an idea what I did wrong? In previous posts you suggested not to set up a new database, but to skip this part and just to set the correct mount points. What is the better way? Sorry I am a little bit confused.
In addition, during the step with mysql_secure_installation I selected "Switch to unix_socket authentication [Y/n]" -> "n". Could this be the problem?
You need to create a new "db" and "files" dataset for a new install of owncloud. The reason is that you can validate owncloud will start properly.
If it was not working to begin with, there is no point targeting the old "db" and "files" datasets yet.
But if you were successfull at installing a new owncloud instance, then you can update the mount points to the old "db" and "files" dataset.

If your install was successful, then the reason MySQL wouldn't start after changing the mount point could simply be due to an incorrect parameter in the config.php file, I think.

Make sure the following parameters match your old config.php setup:

'passwordsalt' => ...
'secret' => ...
'dbname' => ...
'dbtableprefix' => ...
'dbuser' => ...
'dbpassword' => ...
'instanceid' => ...


Then once changed, restart you jail.
 

frank_drebin

Cadet
Joined
Jan 23, 2020
Messages
3
You need to create a new "db" and "files" dataset for a new install of owncloud. The reason is that you can validate owncloud will start properly.
If it was not working to begin with, there is no point targeting the old "db" and "files" datasets yet.
But if you were successfull at installing a new owncloud instance, then you can update the mount points to the old "db" and "files" dataset.

If your install was successful, then the reason MySQL wouldn't start after changing the mount point could simply be due to an incorrect parameter in the config.php file, I think.

Make sure the following parameters match your old config.php setup:

'passwordsalt' => ...
'secret' => ...
'dbname' => ...
'dbtableprefix' => ...
'dbuser' => ...
'dbpassword' => ...
'instanceid' => ...


Then once changed, restart you jail.

Okay, the validation actually makes sense. I was finally able to start MySQL and now everything works as expected. The problem was not the config.php (all parameters matched my old setup), but the old jail was still running and therefore connected to the mysql database. I actually wanted to leave the old jail untouched until the new one was running without problems, but after I stopped the old jail and gave the new jail writing permission to the db, it finally worked. Thanks for your help @Apollo !
 
Top