Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails when using Postgres (pgsql) #219

Open
Blingoose opened this issue Apr 27, 2024 · 7 comments
Open

Installation fails when using Postgres (pgsql) #219

Blingoose opened this issue Apr 27, 2024 · 7 comments

Comments

@Blingoose
Copy link

Blingoose commented Apr 27, 2024

pgsql installation doesn't work. I'll provide the correct log later.

@Blingoose
Copy link
Author

Blingoose commented Apr 28, 2024

Here is the relevant part from the log:

go: downloading cloud.google.com/go/compute v1.23.0
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.2.5
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
2024/04/28 05:38:35 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /usr/local/bin/caddy -tags nobadger
2024/04/28 05:39:04 [INFO] Build complete: /usr/local/bin/caddy
2024/04/28 05:39:04 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-04-28-0537.2986694524
+ FILE=latest-29.tar.bz2
+ iocage exec nextcloud fetch -o /tmp https://download.nextcloud.com/server/releases/latest-29.tar.bz2 https://download.nextcloud.com/server/releases/latest-29.tar.bz2.asc
/tmp/latest-29.tar.bz2                                 197 MB 9528 kBps    21s
/tmp/latest-29.tar.bz2.asc                             833  B    9 MBps    00s
+ iocage exec nextcloud fetch -o /tmp https://nextcloud.com/nextcloud.asc
/tmp/nextcloud.asc                                    3100  B   17 MBps    00s
+ iocage exec nextcloud gpg --import /tmp/nextcloud.asc
gpg: Warning: using insecure memory!
gpg: directory '/root/.gnupg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D75899B9A724937A: public key "Nextcloud Security <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
+ iocage exec nextcloud gpg --verify /tmp/latest-29.tar.bz2.asc
gpg: Warning: using insecure memory!
gpg: assuming signed data in '/tmp/latest-29.tar.bz2'
gpg: Signature made Tue Apr 23 08:14:25 2024 PDT
gpg:                using RSA key 28806A878AE423A28372792ED75899B9A724937A
gpg: Good signature from "Nextcloud Security <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2880 6A87 8AE4 23A2 8372  792E D758 99B9 A724 937A
+ iocage exec nextcloud tar xjf /tmp/latest-29.tar.bz2 -C /usr/local/www/
+ iocage exec nextcloud chown -R www:www /usr/local/www/nextcloud/
+ [ pgsql '=' mariadb ]
+ [ pgsql '=' pgsql ]
+ iocage exec nextcloud sysrc 'postgresql_enable=YES'
postgresql_enable:  -> YES
+ iocage exec nextcloud sysrc 'redis_enable=YES'
redis_enable:  -> YES
+ iocage exec nextcloud sysrc 'php_fpm_enable=YES'
php_fpm_enable:  -> YES
+ [ 0 -eq 1 ]
+ iocage exec nextcloud cp -f /mnt/includes/php.ini /usr/local/etc/php.ini
+ iocage exec nextcloud chown -R www:www /usr/local/etc/php.ini
+ iocage exec nextcloud cp -f /mnt/includes/redis.conf /usr/local/etc/redis.conf
+ iocage exec nextcloud cp -f /mnt/includes/www.conf /usr/local/etc/php-fpm.d/
+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ iocage exec nextcloud cp -f /mnt/includes/remove-staging.sh /root/
+ [ 0 -eq 1 ]
+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ echo $'Copying Caddyfile for Let\'s Encrypt DNS cert'
Copying Caddyfile for Let's Encrypt DNS cert
+ iocage exec nextcloud cp -f /mnt/includes/Caddyfile-dns /usr/local/www/Caddyfile
+ iocage exec nextcloud cp -f /mnt/includes/caddy /usr/local/etc/rc.d/
+ [ pgsql '=' mariadb ]
+ iocage exec nextcloud sed -i '' s/yourhostnamehere/nextcloudinstance.com/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/dns_plugin/cloudflare/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/api_token/HSkctZtNllWRqisi-uD6nOeqWmCps0Cgm0qWtxqg/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/jail_ip/192.168.1.23/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/youremailhere/[email protected]/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' 's|mytimezone|Asia/Tokyo|' /usr/local/etc/php.ini
+ iocage exec nextcloud sysrc 'caddy_enable=YES'
caddy_enable:  -> YES
+ iocage exec nextcloud sysrc 'caddy_config=/usr/local/www/Caddyfile'
caddy_config:  -> /usr/local/www/Caddyfile
+ iocage restart nextcloud
* Stopping nextcloud
  + Executing prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing devfs_ruleset: 1000 OK
  + Removing jail process OK
  + Executing poststop OK
No default gateway found for ipv6.
* Starting nextcloud
  + Started OK
  + Using devfs_ruleset: 1000 (iocage generated default)
  + Configuring VNET OK
  + Using IP options: vnet
  + Starting services OK
  + Executing poststart OK
+ iocage exec nextcloud pw usermod www -G redis
+ iocage exec nextcloud chmod 777 /var/run/redis/redis.sock
+ [ '' '==' true ]
+ [ pgsql '=' mariadb ]
+ [ pgsql '=' pgsql ]
+ iocage exec nextcloud cp -f /mnt/includes/pgpass /root/.pgpass
+ iocage exec nextcloud chmod 600 /root/.pgpass
+ iocage exec nextcloud chown postgres /var/db/postgres/
+ iocage exec nextcloud /usr/local/etc/rc.d/postgresql initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  C
  CTYPE:    C.UTF-8
  MESSAGES: C.UTF-8
  MONETARY: C.UTF-8
  NUMERIC:  C.UTF-8
  TIME:     C.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/db/postgres/data13 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... US/Pacific
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/pg_ctl -D /var/db/postgres/data13 -l logfile start

+ iocage exec nextcloud su -m postgres -c '/usr/local/bin/pg_ctl -D /var/db/postgres/data13 start'
waiting for server to start....2024-04-28 05:40:03.716 PDT [23491] LOG:  endinglog output to stderr
2024-04-28 05:40:03.716 PDT [23491] HINT:  Future log output will go to log destination "syslog".
 done
server started
+ iocage exec nextcloud sed -i '' 's|mypassword|yPqyBDP2mTGTU0G4XtiDRA==|' /root/.pgpass
+ iocage exec nextcloud psql -U postgres -c 'CREATE DATABASE nextcloud;'
CREATE DATABASE
+ iocage exec nextcloud psql -U postgres -c $'CREATE USER nextcloud WITH ENCRYPTED PASSWORD \'jmI+aBR3io9jUGwbYtiQgA==\';'
CREATE ROLE
+ iocage exec nextcloud psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;'
GRANT
+ iocage exec nextcloud psql -U postgres -c 'SELECT pg_reload_conf();'
 pg_reload_conf
----------------
 t
(1 row)

+ echo 'PostgreSQL root password is yPqyBDP2mTGTU0G4XtiDRA=='
+ echo 'Nextcloud database password is jmI+aBR3io9jUGwbYtiQgA=='
+ echo 'Nextcloud Administrator password is PMRX95mjfWXjApJo'
+ iocage exec nextcloud mkdir -p /var/log/nextcloud/
+ iocage exec nextcloud chown www:www /var/log/nextcloud
+ [ pgsql '=' mariadb ]
+ [ pgsql '=' pgsql ]
+ iocage exec nextcloud su -m www -c 'php /usr/local/www/nextcloud/occ maintenance:install --database="pgsql" --database-name="nextcloud" --database-user="nextcloud" --database-pass="jmI+aBR3io9jUGwbYtiQgA==" --database-host="localhost:/tmp/.s.PGSQL.5432" --admin-user="admin" --admin-pass="PMRX95mjfWXjApJo" --data-dir="/mnt/files"'
No database drivers (sqlite, mysql, or postgresql) installed.


An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /usr/local/www/nextcloud/lib/private/Console/Application.php:167
Stack trace:
#0 /usr/local/www/nextcloud/console.php(112): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/local/www/nextcloud/occ(11): require_once('/usr/local/www/...')
#2 {main}{"reqId":"bqYDNOlW36cwk3fJwbQw","level":3,"time":"2024-04-28T12:40:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fopen(/usr/local/www/nextcloud/config/config.php): Failed to open stream: No such file or directory at /usr/local/www/nextcloud/lib/private/Config.php#225","userAgent":"--","version":"","data":{"app":"PHP"}}
Command: su -m www -c php /usr/local/www/nextcloud/occ maintenance:install --database="pgsql" --database-name="nextcloud" --database-user="nextcloud" --database-pass="jmI+aBR3io9jUGwbYtiQgA==" --database-host="localhost:/tmp/.s.PGSQL.5432"--admin-user="admin" --admin-pass="PMRX95mjfWXjApJo" --data-dir="/mnt/files" failed!
+ echo 'Failed to install Nextcloud, aborting'
Failed to install Nextcloud, aborting
+ exit 1

Command exit status: 1
Script done on Sun Apr 28 05:40:10 2024

@danb35
Copy link
Owner

danb35 commented Apr 28, 2024

tl;dr: Unless you really want to use Postgres, you might be better off just using MariaDB. It's been tested more and seems to work pretty well.

The current version of this script installs Postgres 13. But even though that's a currently-maintained version, it doesn't seem to be able to coexist with the php82-pgsql package, which is the reason for the No database drivers (sqlite, mysql, or postgresql) installed. error you're seeing.

So the obvious next step would be to install a newer version of Postgres, like 15. But that leads to other problems I haven't tracked down yet.

@Blingoose
Copy link
Author

Blingoose commented Apr 28, 2024

MariaDB it is. Just out of curiosity, is there any particular reason for not using php83 and let's say MariaDB 10.11?

@danb35
Copy link
Owner

danb35 commented Apr 28, 2024

MariaDB versions get pretty good long-term support, and 10.6 is what Nextcloud themselves still recommend. I recall having problems using a newer version, but I don't recall what they were. As to PHP 8.3, I frankly hadn't been tracking that. I can see how the script works if I update to it, but it'll probably take me a couple of days.

@Blingoose
Copy link
Author

Indeed they recommend 10.6, I didn't pay attention, thanks. I'll try php83 with mdb10.6 and see what's up

@danb35
Copy link
Owner

danb35 commented Apr 29, 2024

I updated the script this morning to install PHP 8.3 rather than 8.2. With that, MariaDB, and Nextcloud 29, it installs without issues and doesn't give any errors in the admin page other than that HSTS isn't enabled (which is by design). Let me know how it works for you.

@Blingoose
Copy link
Author

I'm running the same configuration for about 12 or more hours and it's been flawless. No issues encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants