Installing Nextcloud

I have the following script to install all the packages I need for nextcloud, but for some reason it runs without any errors although postgresql18-server does not get installed.

Can anyone explain what the problem could be?

Installing it separately works without any problem.


sh:
echo -n 'pkg install -y '> nextcloud-install.sh
cat << EOF | tr '\n' ' ' >> nextcloud-install.sh
nextcloud-php84
postgresql18-server
php84
php84-pgsql
php84-gd
php84-curl
php84-zip
php84-mbstring
php84-intl
php84-bcmath
php84-gmp
php84-opcache
php84-pecl-APCu
php84-pecl-imagick
php84-exif
php84-fileinfo
php84-posix
php84-sockets
php84-ldap
php84-pecl-redis
caddy
redis
EOF
 
I have the following script to install all the packages I need for nextcloud, but for some reason it runs without any errors although postgresql18-server does not get installed.

Can anyone explain what the problem could be?

Installing it separately works without any problem.


sh:
echo -n 'pkg install -y '> nextcloud-install.sh
cat << EOF | tr '\n' ' ' >> nextcloud-install.sh
nextcloud-php84
postgresql18-server
php84
php84-pgsql
php84-gd
php84-curl
php84-zip
php84-mbstring
php84-intl
php84-bcmath
php84-gmp
php84-opcache
php84-pecl-APCu
php84-pecl-imagick
php84-exif
php84-fileinfo
php84-posix
php84-sockets
php84-ldap
php84-pecl-redis
caddy
redis
EOF
You need the shebang line at the top of the script.

Code:
#!/bin/sh
 
I have the following script to install all the packages I need for nextcloud, but for some reason it runs without any errors although postgresql18-server does not get installed.

Can anyone explain what the problem could be?

Installing it separately works without any problem.


sh:
echo -n 'pkg install -y '> nextcloud-install.sh
cat << EOF | tr '\n' ' ' >> nextcloud-install.sh
nextcloud-php84
postgresql18-server
php84
php84-pgsql
php84-gd
php84-curl
php84-zip
php84-mbstring
php84-intl
php84-bcmath
php84-gmp
php84-opcache
php84-pecl-APCu
php84-pecl-imagick
php84-exif
php84-fileinfo
php84-posix
php84-sockets
php84-ldap
php84-pecl-redis
caddy
redis
EOF

You need to execute the nextcloud-install.sh that it builds.
 
I'm trying again following suggestion by victort. This seems to work at the moment. I'll see if anything is missing.

sh:
echo -n 'pkg install -y '> nextcloud-install.sh
cat << EOF | tr '\n' ' ' >> nextcloud-install.sh
nextcloud-php84
caddy
redis
postgresql18-server
EOF
 
The script installs caddy as the webserver, either mariadb or postgres depending on what you choose as the database, and configures the admin user with a random password.

All the info is shown at the end and saved inside the root directory.

Once finished the webserver will be running, the database will be set up and configured, and an initial admin user. Yes you can change the admin password inside the script if you don’t want the random one.
I've tried running the script numerous times and it fails to install postgresql.

I amended the variables at the top of the script as shown below.

Here is the last part of a logfile produced when running the script:-

sh:
#!/bin/sh
# Install Nextcloud

APP_NAME="Nextcloud"
APP_VERSION="32"
ADMIN_PASSWORD="ADMIN"
MX_WINDOW="5"
DB_TYPE="PostgreSQL"
DB_NAME="nextcloud"
DB_USER="nextcloud"
DB_ROOT_PASSWORD="ADMIN"
DB_PASSWORD="ADMIN"
NO_CERT=1
SELFSIGNED_CERT=1
STANDALONE_CERT=0
DNS_CERT=0
DNS_PLUGIN=""
DNS_TOKEN=""
CERT_EMAIL=""
COUNTRY_CODE="GB"
HOST_NAME="nextcloud"
TIME_ZONE="GMT"
PHP_VERSION="84"
MARIADB_VERSION="118"
PG_VERSION="18"
Code:
+ chmod 600 /root/.pgpass
+ sed -i '' 's|mypassword|ADMIN|' /root/.pgpass
+ mkdir /var/db/postgres
mkdir: /var/db/postgres: File exists
+ chown postgres /var/db/postgres
chown: postgres: illegal user name
+ service postgresql initdb
postgresql does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
+ service postgresql start
postgresql does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
+ psql -U postgres -c $'CREATE DATABASE nextcloud TEMPLATE template0 ENCODING \'UTF8\';'
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
+ echo 'Failed to create Nextcloud database, aborting'
Failed to create Nextcloud database, aborting
+ exit 1

Command exit status: 1
Script done on Wed Mar 18 21:54:29 2026
 
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
Iirc early-on I couldn't get sockets working for PHP-FPM stuff and/or MariaDB connections on FreeBSD; I used ports instead (127.0.0.1:9001 vs site.sock)

Like with WordPress I had to set define( 'DB_HOST', '127.0.0.1' ); vs using localhost Windows/Linux
 
Iirc early-on I couldn't get sockets working for PHP-FPM stuff and/or MariaDB connections on FreeBSD; I used ports instead (127.0.0.1:9001 vs site.sock)

Like with WordPress I had to set define( 'DB_HOST', '127.0.0.1' ); vs using localhost Windows/Linux
The error occurs because postgresql didn't get installed.

This seems to be related to postgresql18. After changing to 17 things went smoothly.
 
Can you check that postgresql18-server was actually installed successfully? The error message 'chown: postgres: illegal user name' makes it seem that the postgres user hasn't been created, which is part of the postgresql18-server installation script. If the installation wasn't successful that would also explain the error message 'postgresql does not exist in /etc/rc.d or the local startup directories (/usr/local/etc/rc.d), or is not executable'. If you can post the relevant parts of the nextcloud script that installs and sets up postgresql that would help.
 
The error occurs because postgresql didn't get installed.
It looks like the installation fails but the script continues. The errors that you've posted are the ones after the initial installation has failed. Are there any error messages prior to the ones that you posted above?
 
Can you check that postgresql18-server was actually installed successfully? The error message 'chown: postgres: illegal user name' makes it seem that the postgres user hasn't been created, which is part of the postgresql18-server installation script. If the installation wasn't successful that would also explain the error message 'postgresql does not exist in /etc/rc.d or the local startup directories (/usr/local/etc/rc.d), or is not executable'. If you can post the relevant parts of the nextcloud script that installs and sets up postgresql that would help.
I get this in my log:


Code:
        postgresql17-client: 17.9 [FreeBSD-ports]
[nextcloud] [5/8] Fetching postgresql17-client-17.9: 100%    4 MiB   3.8 M/s    00:01   
  - postgresql17-client-17.9 [FreeBSD-ports] conflicts with postgresql18-client-18.3 [FreeBSD-ports] on /usr/local/bin/clusterdb
        postgresql17-client: 17.9 [FreeBSD-ports]
[nextcloud] [4/6] Installing postgresql17-client-17.9...
[nextcloud] [4/6] Extracting postgresql17-client-17.9: 100%
Message from postgresql17-client-17.9:
 
Those messages relate to the client. Any messages relating to the postgresql server?
Originally I put 18 into the variables but that caused a problem. When I changed it to 17 the postgresql17-server did get installed.

I'll pursue the problem about 18 not getting installed once I manage to get nextcloud working.

Looks like I may have bitten off more than I can chew with this application.
 
Suggestion(s):
1. try to get into the habit of using `pkg search -Q full <pkg>`
2. try to get in the habit of using pkg origins.
3. try to get into the habit of using "glob". -e.g. `pkg search -g "php8[0-9]-f*"`.
 
Suggestion(s):
1. try to get into the habit of using `pkg search -Q full <pkg>`
2. try to get in the habit of using pkg origins.
3. try to get into the habit of using "glob". -e.g. `pkg search -g "php8[0-9]-f*"`.
The problem is searching for something which doesn't exist finds nothing.

Whilst the program php-fpm does exist, it is not a dedicated pkg. I haven't figured what actually installs it.
 
Back
Top