For the complete documentation index, see llms.txt. This page is also available as Markdown.

38.7 Nextcloud Cloud Service (with PostgreSQL)

Nextcloud is a self-hosted cloud storage and collaboration platform that provides file management, calendar, contacts, and online office functionality.

Installing Nextcloud

To simplify the installation process, using Ports rather than the pkg package manager is recommended.

# cd /usr/ports/www/nextcloud/
# make config # Configure only the Nextcloud core

This section selects enabling PGSQL, SMB, and PCNTL; uncheck MYSQL:

nextcloud Port

Use Ports to compile and install Nextcloud by executing the following command.

Directory Structure

The Nextcloud file directory structure is as follows.

Installing and Configuring PostgreSQL

Nextcloud requires a database to store data; this section uses PostgreSQL. Install PostgreSQL (ensure its version is consistent with the postgresql-client installed via Ports above).

This section requires installing postgresql16-server, and completing initialization and service auto-start.

Note

If installing using pkg, you also need to install the Port databases/php83-pdo_pgsql; the PHP version numbers must all be consistent.

After PostgreSQL initialization is complete, execute the following commands to create the database and user:

Tip

If you need remote access to the database server, you must modify the /var/db/postgres/data16/pg_hba.conf file to allow user nextcloud to connect to PostgreSQL from a specified IP using SCRAM-SHA-256 authentication.

Example (the IP segment 10.0.50.5/32 needs to be modified according to actual conditions):

Installing mod_php

Nextcloud's frontend requires PHP access, so the PHP Apache module must be installed. You can check the current PHP version using the php -v command to ensure it matches the system-installed version:

Install mod_php using pkg by executing the following command.

Set the PHP-FPM service to start at boot and start the service:

Based on Apache

If using Apache as the web server, corresponding configuration is needed so that Apache can correctly handle Nextcloud's PHP files. Refer to other sections to complete Apache installation and service auto-start.

Viewing Apache Configuration Method

View the Apache configuration method for mod_php83:

Start the Apache 24 service:

Starting Nextcloud

After all configuration is complete, you can access Nextcloud through a browser to complete the initial setup. Access http://ip/nextcloud, replacing ip with the LAN IP address.

Nextcloud FreeBSD Installation Interface

Enter the desired login account and password; other settings can be referenced from the image below.

Nextcloud FreeBSD Installing

After installation is complete, you will be redirected to plugin recommendations; you can ignore the recommendation page and reopen http://ip/nextcloud to start using it.

Nextcloud FreeBSD After Installation
Nextcloud FreeBSD Start Interface

Mounting Samba Shares in Nextcloud

Nextcloud supports mounting external storage, such as Samba shares. The corresponding PHP module must be installed first.

Installing the php83-pecl-smbclient Module

Install the module on the Nextcloud server side.

  • Install using pkg:

  • Or install using Ports:

  • Restart the Apache 24 service to apply configuration changes:

Setting Up Samba Shares

After installing the module, you need to enable the external storage support application in Nextcloud and complete the corresponding configuration. Go to the "Apps" page:

Nextcloud Samba Share

Find the "External storage support" application and enable it (disabled by default).

Nextcloud Samba Share

Go to administration settings:

Nextcloud Samba Share

Locate the external storage under Administration (not the external storage under "Personal").

Nextcloud Samba Share

View all files; Samba is enabled:

Nextcloud Samba Share

Unfinished Items

Nextcloud has several other commonly used plugins that can be installed. Other common plugins can be found using the command pkg search -x nextcloud | grep php83, then installed via pkg.

Tip

In some versions, permission issues may occur when initializing Nextcloud; please check the access permissions of the config directory and its files in /usr/local/www/nextcloud to ensure the user running Apache has read and write permissions.

References

Last updated