Resource icon

Scripted installation of Nextcloud 28 in iocage jail 2018-03-23

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Do you think i should remove caddy and swap for apache?
You might as well manually install in that case.

But I'm wondering if the problem isn't something simpler: When you set up NPM to proxy for this, did you set its target to the hostname or to the IP address of your Nextcloud jail? If the latter, change it to the former, or look into the use of the default_sni directive in the Caddyfile.
 

tassevem

Dabbler
Joined
Oct 14, 2023
Messages
13
You might as well manually install in that case.

But I'm wondering if the problem isn't something simpler: When you set up NPM to proxy for this, did you set its target to the hostname or to the IP address of your Nextcloud jail? If the latter, change it to the former, or look into the use of the default_sni directive in the Caddyfile.
The hostname is the ip...

1698009476466.png


Do I just remove the "#" coment?
 

tassevem

Dabbler
Joined
Oct 14, 2023
Messages
13
Sorry. It is not. It is the 1.12. unknown5a1b1795041b.lan

This cant be the correct hostname. Do you know how I can check the hostname?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Do you know how I can check the hostname?
It would be whatever you set in the config file when you created the jail. Alternatively, you can find it in the Caddyfile in the jail.

Honestly, if you want a reverse proxy to other apps, the simpler way to go would be to ditch NPM entirely, forward 80/443 to your Nextcloud jail, and set up its Caddyfile to handle the proxies to anything else. There's no GUI for it, but it's trivial in the Caddyfile:

Code:
host.domain.tld {
    reverse_proxy 192.168.1.60:8080
}
 
Last edited:

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
Hello all, I recently wanted to update the PHP version of my Nextcloud jail and I think I broke it...
  1. I updated Nextcloud to the last version trough the GUI then see the warning message to update PHP version to 8.2
  2. Running pkg update & pkg upgrade in my Nextcloud jail
  3. Tried to update the version of my jail with run iocage upgrade -r 13.1-RELEASE nextcloud. I think something went wrong here, it endend with error on a file I don't remember the name.
  4. Stopped / restarted the jail, stuck in 12.2 version
  5. Anyway, tried to use pkg install nextcloud-php82
After that, my Nextcloud is no longer accessible.
Tried to roll-back with snapshots (nextcloud + nextcloud-root) without success.
I receive this message "Downgrading is not supported and is likely to cause unpredictable issues"

How can I create a new jail and connect it to my "old" Nextcloud data ?
Thank you !
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Hello all, I recently wanted to update the PHP version of my Nextcloud jail and I think I broke it...
  1. I updated Nextcloud to the last version trough the GUI then see the warning message to update PHP version to 8.2
  2. Running pkg update & pkg upgrade in my Nextcloud jail
  3. Tried to update the version of my jail with run iocage upgrade -r 13.1-RELEASE nextcloud. I think something went wrong here, it endend with error on a file I don't remember the name.
  4. Stopped / restarted the jail, stuck in 12.2 version
  5. Anyway, tried to use pkg install nextcloud-php82
After that, my Nextcloud is no longer accessible.
Tried to roll-back with snapshots (nextcloud + nextcloud-root) without success.
I receive this message "Downgrading is not supported and is likely to cause unpredictable issues"

How can I create a new jail and connect it to my "old" Nextcloud data ?
Thank you !
Since you are in the latest Nextcloud version, you should be able to just run the script again and point it at the old dataset.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
Since you are in the latest Nextcloud version, you should be able to just run the script again and point it at the old dataset.
Ok, run the script as if it was a fresh install using the same folder in the POOL_PATH setting ?
There will be no need to recreate users and everything else ?

It will be perfect :grin:
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Ok, run the script as if it was a fresh install using the same folder in the POOL_PATH setting ?
There will be no need to recreate users and everything else ?

It will be perfect :grin:
Correct. The script recognizes it as a reinstall.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
...and for future reference, never do anything with the Nextcloud packages in this jail--the script doesn't use them; it installs Nextcloud from source. As a result, pkg install nextcloud or anything similar is likely to break things quite badly.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
...and for future reference, never do anything with the Nextcloud packages in this jail--the script doesn't use them; it installs Nextcloud from source. As a result, pkg install nextcloud or anything similar is likely to break things quite badly.
Ok, tried to reinstall but I think I do something wrong because I've got this message in red at the end : "Username is invalid because files already exist for this user"

My Nextcloud folders on Truenas :
CONFIG > mnt/datapool/apps/nextcloud/config
THEMES > mnt/datapool/apps/nextcloud/themes
DB > mnt/datapool/apps/nextcloud/db
FILES > mnt/datapool/media/cloud

The nextcloud-config file :
JAIL_IP="192.168.1.100"
DEFAULT_GW_IP="192.168.1.1"
POOL_PATH="/mnt/datapool"
TIME_ZONE="Europe/Paris"
HOST_NAME="cloud.domain.fr"
STANDALONE_CERT=1
CERT_EMAIL="bonjour@domain.fr"
FILES_PATH="mnt/datapool/media/cloud"

When I connect to cloud.domain.fr I come across the Nextcloud interface, but it asks me to create an administrator account and choose the database storage. My login and password don't work.

Also I renamed the broken jail into "nextcloud-dead" before reinstall, do I have to delete it ?
Thank's
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Ok, tried to reinstall but I think I do something wrong because I've got this message in red at the end : "Username is invalid because files already exist for this user"

My Nextcloud folders on Truenas :
CONFIG > mnt/datapool/apps/nextcloud/config
THEMES > mnt/datapool/apps/nextcloud/themes
DB > mnt/datapool/apps/nextcloud/db
FILES > mnt/datapool/media/cloud

The nextcloud-config file :
JAIL_IP="192.168.1.100"
DEFAULT_GW_IP="192.168.1.1"
POOL_PATH="/mnt/datapool"
TIME_ZONE="Europe/Paris"
HOST_NAME="cloud.domain.fr"
STANDALONE_CERT=1
CERT_EMAIL="bonjour@domain.fr"
FILES_PATH="mnt/datapool/media/cloud"

When I connect to cloud.domain.fr I come across the Nextcloud interface, but it asks me to create an administrator account and choose the database storage. My login and password don't work.

Also I renamed the broken jail into "nextcloud-dead" before reinstall, do I have to delete it ?
Thank's
POOL_PATH should be set to /mnt/datapool/apps instead of /mnt/datapool since thats where the old data is.

It sounds like it's not finding the database, in which case you will need to set the above POOL_PATH properly in the config file.
Keep the old jail until you know for sure that the new one works.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
POOL_PATH should be set to /mnt/datapool/apps instead of /mnt/datapool since thats where the old data is.

It sounds like it's not finding the database, in which case you will need to set the above POOL_PATH properly in the config file.
Keep the old jail until you know for sure that the new one works.
Everything went well the second time except towards the end with a problem connecting to the database.
See below :
+ echo 'Reinstall detected, skipping generation of new config and database'
Reinstall detected, skipping generation of new config and database
+ [ mariadb '=' mariadb ]
+ iocage exec nextcloud cp -f /mnt/includes/my.cnf /root/.my.cnf
+ iocage exec nextcloud sed -i '' 's|mypassword|GWgn+NpBq5u8BXNaGVhL1w==|' /root/.my.cnf
+ iocage exec nextcloud su -m www -c 'php -f /usr/local/www/nextcloud/cron.php'
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:140
Stack trace:
#0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /usr/local/www/nextcloud/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM `...', Array, Array, NULL)
#3 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery('SELECT * FROM `...', Array, Array)
#4 /usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /usr/local/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /usr/local/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /usr/local/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /usr/local/www/nextcloud/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues(false, 'installed_versi...')
#9 /usr/local/www/nextcloud/lib/private/Server.php(736): OC_App::getAppVersions()
#10 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#11 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#12 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#13 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', true)
#14 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#15 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get('OC\\Memcache\\Fac...')
#16 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#17 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#18 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\ICacheFacto...')
#19 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OCP\\ICacheFacto...', true)
#20 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\ICacheFacto...')
#21 /usr/local/www/nextcloud/lib/private/Server.php(1130): OC\AppFramework\Utility\SimpleContainer->get('OCP\\ICacheFacto...')
#22 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#23 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#24 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#25 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', true)
#26 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#27 /usr/local/www/nextcloud/lib/private/Server.php(2088): OC\AppFramework\Utility\SimpleContainer->get('OCP\\Lock\\ILocki...')
#28 /usr/local/www/nextcloud/lib/private/Files/View.php(107): OC\Server->getLockingProvider()
#29 /usr/local/www/nextcloud/lib/private/Server.php(470): OC\Files\View->__construct()
#30 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#31 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#32 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#33 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', true)
#34 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#35 /usr/local/www/nextcloud/lib/private/Server.php(1490): OC\AppFramework\Utility\SimpleContainer->get('OC\\Files\\Node\\H...')
#36 /usr/local/www/nextcloud/lib/base.php(635): OC\Server->boot()
#37 /usr/local/www/nextcloud/lib/base.php(1196): OC::init()
#38 /usr/local/www/nextcloud/cron.php(43): require_once('/usr/local/www/...')
#39 {main}
Command: su -m www -c php -f /usr/local/www/nextcloud/cron.php failed!
+ iocage exec nextcloud crontab -u www /mnt/includes/www-crontab
+ iocage fstab -r nextcloud /mnt/datapool/media/freenas-iocage-nextcloud/includes /mnt/includes nullfs rw 0 0
Successfully removed mount from nextcloud's fstab
+ echo 'Installation complete!'
Installation complete!
+ [ 0 -eq 1 ]
+ echo 'Using your web browser, go to https://cloud.domain.fr to log in'
Using your web browser, go to https://cloud.domain.fr to log in
+ [ true '==' true ]
+ echo 'You did a reinstall, please use your old database and account credentials'
You did a reinstall, please use your old database and account credentials
+ echo ''

+ [ 1 -eq 1 ]
+ echo $'You have obtained your Let\'s Encrypt certificate using the staging server.'
You have obtained your Let's Encrypt certificate using the staging server.
+ echo 'This certificate will not be trusted by your browser and will cause SSLerrors'
This certificate will not be trusted by your browser and will cause SSL errors
+ echo $'when you connect. Once you\'ve verified that everything else is working'
when you connect. Once you've verified that everything else is working
+ echo 'correctly, you should issue a trusted certificate. To do this, run:'
correctly, you should issue a trusted certificate. To do this, run:
+ echo ' iocage exec nextcloud /root/remove-staging.sh'

Script done, output file is nextcloud.log
When I access to cloud.domain.fr I got this message :
Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
Everything seems to be fine in the config.php, but :
'datadirectory' => '/mnt/files', (not supposed to be /mnt/datapool/media/cloud ?)
'dbhost' => 'localhost:/tmp/mysql.sock' (tried to change it to 'localhost:/var/run/mysql/mysql.sock' without success)
 
Last edited:

victort

Guru
Joined
Dec 31, 2021
Messages
973
Everything went well the second time except towards the end with a problem connecting to the database.
See below :

When I access to cloud.domain.fr I got this message :

Everything seems to be fine in the config.php, but :
That is the path inside the jail, it is correct.
Also leave the dbhost value at /var/run/mysql/mysql.sock

We need to find out why your database isn’t connecting.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
That is the path inside the jail, it is correct.
Also leave the dbhost value at /var/run/mysql/mysql.sock

We need to find out why your database isn’t connecting.
How can I informations about the database ?
Is there a log or something like that ?
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
How can I informations about the database ?
Is there a log or something like that ?
Im assuming your database is still there at /mnt/datapool/apps/nextcloud/db/mariadb is it?

Try service mysql-server status from inside the jail to see if it is running.

I hope your previous commands in the old jail did not do anything to mess up your database.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
Im assuming your database is still there at /mnt/datapool/apps/nextcloud/db/mariadb is it?

Try service mysql-server status from inside the jail to see if it is running.

I hope your previous commands in the old jail did not do anything to mess up your database.
Yeah I've got this message :
mysql is not running
What to do with that ?
 

victort

Guru
Joined
Dec 31, 2021
Messages
973

Follow the step here to remove the old my.cnf file, then re-run the script.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14

Follow the step here to remove the old my.cnf file, then re-run the script.
Ok, here's what I do
rm /var/db/mysql/my.cnf
To delete the old my.cnf file in the jail.
I deleted the Nextcloud jail and re-ran the installation script from the freenas-iocage-nextcloud
script nextcloud.log ./nextcloud-jail.sh
Installation completed, but I still get the same error message
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
BUT tested service mysql-server status
mysql is running as pid 61147.
 

fredotask

Dabbler
Joined
Jan 6, 2022
Messages
14
Ok, here's what I do

To delete the old my.cnf file in the jail.
I deleted the Nextcloud jail and re-ran the installation script from the freenas-iocage-nextcloud

Installation completed, but I still get the same error message

BUT tested service mysql-server status
Solved it by changing the config file /mnt/mypool/nextcloud/config/config.php
Changing 'dbhost' option from 'localhost:/tmp/mysql.sock' to 'localhost:/var/run/mysql/mysql.sock' like you do in the other thread.

Restarted the jail and Nextcloud launching in maintenance mode...
In the config.php file there is a maintenance option
Changed 'maintenance' => true, to false, saved changes and refreshed the web page

Nextcloud is back :grin::grin::grin::grin:
THANK YOU @victort for your help :wink:
 
Top