Installing Nextcloud

Am finally going to install Nextcloud.

Can anyone tell me if these are the requireds pkgs for Nexcloud (using Postgresql)?

pkg install nextcloud postgresql16-server apache24 php82 php82-pgsql php82-gd php82-curl php82-zip php82-mbstring php82-intl php82-bcmath php82-gmp php82-opcache

This is according to ChatGPT, which often gets things wrong so I thought I'd run it by the experts first before I start.
 
Nextcloud package seems to support MySQL by default for database.

The web server choice seems to be left to the user, I guess.

You could use Apache or nginx as web server.

I also think that php-fpm might be required for nextcloud but it doesn't seem to be a dependency.
 
I've personally been using php83 without any problems with nextcloud. So, you can update at least that far. I feel like I had a reason for not using php84, but I can't remember why and whatever it was could be a non-issue now.
 
According to https://www.sharpwriting.net/project/nextcloud-on-freebsd/#3

Next, we need to configure Apache to handle php files. Go to /usr/local/etc/apache24/Includes and create a new file. I called mine php-fpm.conf but you call it whatever you like as long as it ends in .conf.

PHP:
<FilesMatch \.php$>
    SetHandler proxy:unix:/tmp/php-fpm.sock|fcgi://localhost/
</FilesMatch>

Does that look right?

I thought I needed to add something like this:-

PHP:
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
 

is a six year old guide.

Has anyone seen anything newer using www/nextcloud?
 
Help needed for getting Nextcloud working with PostgreSQL.... The docs linked to do not mention PostgreSQL/

Initial page provides this:-

1773185743810.png
 
I'm trying to get the install script from https://github.com/tschettervictor/bsd-apps/tree/main/nextcloud working but could do with some clarification if anyone is familiar with it.


Code:
# Nextcloud
https://nextcloud.com

### Command to fetch script
```
fetch https://raw.githubusercontent.com/tschettervictor/bsd-apps/main/nextcloud/nextcloud-install.sh
```

Don't forget to
```
chmod +x nextcloud-install.sh
```

## Variables
These are the variables that are available to change along with their defaults and a description of what they do. Other variables should be left at defalut unless you have a good reason to change them.

HOST_NAME
- sets the hostname to use for the webserver
- must be set to your FQDN ie: my.domain.com

TIME_ZONE
- sets the timezone, see http://php.net/manual/en/timezones.php)
- must be set

DB_TYPE
- set your preferred database (currently defaults to mariadb)
- can be either "MariaDB" or "PostgreSQL"

MARIADB_VERSION
- mariadb version to use (currently defaults to 106)

PG_VERSION
- postgres version to use (currently defaults to 16)

APP_VERSION
- set nextcloud version (currently defaults to 29)

PHP_VERSION
- php version to use (currently defaults to 83)

COUNTRY_CODE
- 2 letter ISO code for your country
- must be set

### Cerificate Configuration

Caddy is a webserver that can do automatic TLS and HTTPS for you. You should enable one AND ONLY ONE of the following 4 CERT confiurations to tell the script how you want Caddy to work.

NO_CERT
- no certificate, http access only

STANDALONE_CERT
- fully working cert, must own a domain, and have ports 80 and 443 forwarded to your jail

SELFSIGNED_CERT
- generates a self-signed cert for use with https

DNS_CERT
- DNS validated cert, https access
- must be used together with CERT_EMAIL DNS_TOKEN and DNS_PLUGIN
- must own a domain that allows DNS validation
- will generate a DNS validated cert

DNS_PLUGIN
- set this to a supported DNS plugin, see caddy docs for details
- only used with DNS_CERT

DNS_TOKEN
- must have "Zone / Zone / Read" and "Zone / DNS / Edit" permissions on the domain you are using with Caddy)
- only used with DNS_CERT

CERT_EMAIL
- your email to receive cert expiry
- used with DNS_CERT and STANDALONE_CERT

If you do use any type of certificate with a domain, Caddy will obtain a staging certificate to not excede rate limits. Once you have confirmed things are working, run the script at `/root/remove-staging.sh` to acquire a valid certificate.

All of the above variables should be changed to fit your environment.

For more detailed documentation, see https://github.com/danb35/freenas-iocage-nextcloud

## Mount points (should be mounted outside the jail)
- `/mnt/files` - files directory
- `/usr/local/www/nextcloud/config` - config directory
- Database (mount ONLY ONE depending on your database choice)
  - `/var/db/mysql` - database directory for mariadb
  - `/var/db/postgres` - database directory for postgresql
- `/usr/local/www/nextcloud/themes` - themes directory

## Jail Properties
- `sysvshm=new` - only when using postgres database
 
I'm trying to get the install script from https://github.com/tschettervictor/bsd-apps/tree/main/nextcloud working but could do with some clarification if anyone is familiar with it.


Code:
# Nextcloud
https://nextcloud.com

### Command to fetch script
```
fetch https://raw.githubusercontent.com/tschettervictor/bsd-apps/main/nextcloud/nextcloud-install.sh
```

Don't forget to
```
chmod +x nextcloud-install.sh
```

## Variables
These are the variables that are available to change along with their defaults and a description of what they do. Other variables should be left at defalut unless you have a good reason to change them.

HOST_NAME
- sets the hostname to use for the webserver
- must be set to your FQDN ie: my.domain.com

TIME_ZONE
- sets the timezone, see http://php.net/manual/en/timezones.php)
- must be set

DB_TYPE
- set your preferred database (currently defaults to mariadb)
- can be either "MariaDB" or "PostgreSQL"

MARIADB_VERSION
- mariadb version to use (currently defaults to 106)

PG_VERSION
- postgres version to use (currently defaults to 16)

APP_VERSION
- set nextcloud version (currently defaults to 29)

PHP_VERSION
- php version to use (currently defaults to 83)

COUNTRY_CODE
- 2 letter ISO code for your country
- must be set

### Cerificate Configuration

Caddy is a webserver that can do automatic TLS and HTTPS for you. You should enable one AND ONLY ONE of the following 4 CERT confiurations to tell the script how you want Caddy to work.

NO_CERT
- no certificate, http access only

STANDALONE_CERT
- fully working cert, must own a domain, and have ports 80 and 443 forwarded to your jail

SELFSIGNED_CERT
- generates a self-signed cert for use with https

DNS_CERT
- DNS validated cert, https access
- must be used together with CERT_EMAIL DNS_TOKEN and DNS_PLUGIN
- must own a domain that allows DNS validation
- will generate a DNS validated cert

DNS_PLUGIN
- set this to a supported DNS plugin, see caddy docs for details
- only used with DNS_CERT

DNS_TOKEN
- must have "Zone / Zone / Read" and "Zone / DNS / Edit" permissions on the domain you are using with Caddy)
- only used with DNS_CERT

CERT_EMAIL
- your email to receive cert expiry
- used with DNS_CERT and STANDALONE_CERT

If you do use any type of certificate with a domain, Caddy will obtain a staging certificate to not excede rate limits. Once you have confirmed things are working, run the script at `/root/remove-staging.sh` to acquire a valid certificate.

All of the above variables should be changed to fit your environment.

For more detailed documentation, see https://github.com/danb35/freenas-iocage-nextcloud

## Mount points (should be mounted outside the jail)
- `/mnt/files` - files directory
- `/usr/local/www/nextcloud/config` - config directory
- Database (mount ONLY ONE depending on your database choice)
  - `/var/db/mysql` - database directory for mariadb
  - `/var/db/postgres` - database directory for postgresql
- `/usr/local/www/nextcloud/themes` - themes directory

## Jail Properties
- `sysvshm=new` - only when using postgres database
Since I built this script, what are your questions?
 
Since I built this script, what are your questions?
Thanks for creating this script.

Is it supposed to install a webserver and sql server as part of the installation?

It would be useful if the install included dialog4ports instead of manually editing install.sh.

Can I simply add my own password here as I don't know how this is supposed to work?

ADMIN_PASSWORD=$(openssl rand -base64 12)
 
Thanks for creating this script.

Is it supposed to install a webserver and sql server as part of the installation?

It would be useful if the install included dialog4ports instead of manually editing install.sh.

Can I simply add my own password here as I don't know how this is supposed to work?
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.
 
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.
I've never heard of caddy. Can't I use apache?

I didn't see either caddy or postgreql among the pkgs installed in my iocage jail.

Maybe I should start again and post my edited install.sh...
 
These are the default settings in https://github.com/tschettervictor/bsd-apps/blob/main/nextcloud/nextcloud-install.sh

Code:
/bin/sh
# Install Nextcloud

APP_NAME="Nextcloud"
APP_VERSION="32"
ADMIN_PASSWORD=$(openssl rand -base64 12)
MX_WINDOW="5"
DB_TYPE="MariaDB"
DB_NAME="nextcloud"
DB_USER="nextcloud"
DB_ROOT_PASSWORD=$(openssl rand -base64 16)
DB_PASSWORD=$(openssl rand -base64 16)
NO_CERT=0
SELFSIGNED_CERT=0
STANDALONE_CERT=0
DNS_CERT=0
DNS_PLUGIN=""
DNS_TOKEN=""
CERT_EMAIL=""
COUNTRY_CODE=""
HOST_NAME=""
TIME_ZONE=""
PHP_VERSION="84"
MARIADB_VERSION="118"
PG_VERSION="17"

Preumably I just need to change DB_TYPE to PostgreSQL.

I want the password set to admin.
 
These are the default settings in https://github.com/tschettervictor/bsd-apps/blob/main/nextcloud/nextcloud-install.sh

Code:
/bin/sh
# Install Nextcloud

APP_NAME="Nextcloud"
APP_VERSION="32"
ADMIN_PASSWORD=$(openssl rand -base64 12)
MX_WINDOW="5"
DB_TYPE="MariaDB"
DB_NAME="nextcloud"
DB_USER="nextcloud"
DB_ROOT_PASSWORD=$(openssl rand -base64 16)
DB_PASSWORD=$(openssl rand -base64 16)
NO_CERT=0
SELFSIGNED_CERT=0
STANDALONE_CERT=0
DNS_CERT=0
DNS_PLUGIN=""
DNS_TOKEN=""
CERT_EMAIL=""
COUNTRY_CODE=""
HOST_NAME=""
TIME_ZONE=""
PHP_VERSION="84"
MARIADB_VERSION="118"
PG_VERSION="17"

Preumably I just need to change DB_TYPE to PostgreSQL.

I want the password set to admin.
You can change the password yes. If you do set the database to Postgres you will need to ensure the property of sysvshm is set to the enabled.

You should also set one of the 4 cert options to 1. Probably the self-signed one or the no cert.
 
You can change the password yes. If you do set the database to Postgres you will need to ensure the property of sysvshm is set to the enabled.

You should also set one of the 4 cert options to 1. Probably the self-signed one or the no cert.

Not sure how to set the property of sysvshm to enabled.

Should I be able to install using these settings:- ?


Code:
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=0
SELFSIGNED_CERT=0
STANDALONE_CERT=0
DNS_CERT=0
DNS_PLUGIN=""
DNS_TOKEN=""
CERT_EMAIL=""
COUNTRY_CODE="GB"
HOST_NAME=""
TIME_ZONE="GMT"
PHP_VERSION="84"
MARIADB_VERSION="118"
PG_VERSION="18"

According to freshports you can install one of two packages www/nextcloud or nextcloud-php84

Are these pkgs the same?
 
Not sure how to set the property of sysvshm to enabled.

Should I be able to install using these settings:- ?


Code:
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=0
SELFSIGNED_CERT=0
STANDALONE_CERT=0
DNS_CERT=0
DNS_PLUGIN=""
DNS_TOKEN=""
CERT_EMAIL=""
COUNTRY_CODE="GB"
HOST_NAME=""
TIME_ZONE="GMT"
PHP_VERSION="84"
MARIADB_VERSION="118"
PG_VERSION="18"

According to freshports you can install one of two packages www/nextcloud or nextcloud-php84

Are these pkgs the same?
The pkg version in ports is very different from this script.

You should set HOSTNAME and probably NO_CERT=1
 
According to ChatGPT:

Code:
Here is a simple and clean setup for Nextcloud on FreeBSD using Caddy + PostgreSQL + PHP-FPM.
This stack is simpler than using Apache HTTP Server and works very well for home servers.

1. Install required packages
pkg update

Install everything needed:

pkg install nextcloud-php83 \
php83 php83-fpm php83-pgsql php83-pdo_pgsql \
php83-gd php83-curl php83-zip php83-mbstring \
php83-intl php83-bcmath php83-gmp php83-opcache \
postgresql17-server caddy redis
2. Enable services
sysrc php_fpm_enable=YES
sysrc postgresql_enable=YES
sysrc caddy_enable=YES
sysrc redis_enable=YES

Start them:

service postgresql initdb
service postgresql start
service php-fpm start
service redis start
3. Configure PostgreSQL for Nextcloud

Switch user:

su - postgres

Create database and user:

createuser -P nextcloud
createdb -O nextcloud nextcloud
exit
4. Configure PHP

Copy production configuration:

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Edit:

ee /usr/local/etc/php.ini

Important settings:

memory_limit = 512M
upload_max_filesize = 2G
post_max_size = 2G
date.timezone = Europe/London

Restart PHP:

service php-fpm restart
5. Prepare Nextcloud directories

Nextcloud files:

/usr/local/www/nextcloud

Create data directory:

mkdir /var/db/nextcloud-data
chown -R www:www /var/db/nextcloud-data
6. Configure Caddy

Edit:

/usr/local/etc/caddy/Caddyfile

Example config:

cloud.example.com {

    root * /usr/local/www/nextcloud
    file_server

    php_fastcgi unix//var/run/php-fpm.sock

    encode gzip

    header {
        Strict-Transport-Security "max-age=31536000;"
        X-Content-Type-Options nosniff
        X-Frame-Options SAMEORIGIN
        X-XSS-Protection "1; mode=block"
    }
}
7. Start Caddy
service caddy start

If DNS points to your server, Caddy will automatically obtain HTTPS certificates from Let's Encrypt.

8. Run Nextcloud installer

Open browser:

https://cloud.example.com

Enter:

Database settings

database: PostgreSQL
user: nextcloud
password: yourpassword
database: nextcloud
host: localhost

Data directory:

/var/db/nextcloud-data
9. Configure background jobs
crontab -u www -e

Add:

*/5 * * * * php -f /usr/local/www/nextcloud/cron.php
10. Test Nextcloud
sudo -u www php /usr/local/www/nextcloud/occ status
Why this stack is good
Component    Reason
Caddy    automatic HTTPS
PostgreSQL    best DB for Nextcloud
PHP-FPM    fast PHP execution
Redis    file locking + caching

✅ Result

You get a modern stack:

Caddy
   ↓
PHP-FPM
   ↓
Nextcloud
   ↓
PostgreSQL
 
Back
Top