This documentation describes how to run a Nextcloud instance on an OpenBSD server.
Warning: there is only a basic description for the web server configuration, in this case httpd.
The X11 sets have to be installed on the system because of some fonts which are required for Nextcloud. ¯\_(ツ)_/¯
Install all required packages.
pkg_add bzip2 mariadb-server php php-curl php-gd php-intl php-pdo_mysql php-xml php-zip redis pecl72-redis
Enable the services.
rcctl enable httpd mysqld php72_fpm redis
For installation details see OpenBSD MariaDB.
Important Note: This webserver will be available only via a unixsocket, so important is to set “skip-networking” and comment out “port” so the client uses per default the socket, as described in the installation article.
Download the bzip-tarball, unpack it and create some folders and links for the chroot environment.
ftp -o /var/www/latest-15.tar.bz2 https://download.nextcloud.com/server/releases/latest-15.tar.bz2
tar -xjvf /var/www/latest-15.zip -C /var/www/
chown -R www:www /var/www/nextcloud
mkdir -p /var/www/etc/ssl
cp /etc/resolv.conf /var/www/etc/resolv.conf
cp /etc/ssl/cert.pem /var/www/etc/ssl/cert.pem
cp /etc/ssl/openssl.cnf /var/www/etc/ssl/openssl.cnf
chown -R www:www /var/www/etc
mkdir /var/www/ncdata
chown www:www /var/www/ncdata
mkdir /var/www/redis
chown _redis:_redis /var/www/redis
ln -s /var/www/mysql /mysql
ln -s /var/www/nextcloud /nextcloud
ln -s /var/www/ncdata /ncdata
ln -s /var/www/redis /redis
As of 26.01.2019 there exists a bug, in which some files are missing from the vendor. (maybe already fixed)
ftp -o /var/www/nextcloud/core/vendor/strengthify/strengthify.min.css https://raw.githubusercontent.com/nextcloud/server/stable15/core/vendor/strengthify/strengthify.min.css
ftp -o /var/www/nextcloud/core/vendor/strengthify/jquery.strengthify.min.js https://raw.githubusercontent.com/nextcloud/server/stable15/core/vendor/strengthify/jquery.strengthify.min.js
Start the webserver and access it to configure the instance.
rcctl start httpd redis php72_fpm mysqld
# dbuser: nextcloud
# dbpassword: <password>
# dbname: nextcloud
# dbhost: instead of 127.0.0.1:3306 use localhost:/mysql/mysql.sock
redis.conf
port 0
unixsocket /var/www/redis/redis.sock
unixsocketperm 777
After the installation, edit /var/www/nextcloud/config/config.php, edit this file accordingly to the following example.
Note: configure only for your needs, in this example a reverse proxy is used, which may be not used in your case. It’s recommended to read this doc https://docs.nextcloud.com/server/15/admin_manual/configuration_server/config_sample_php_parameters.html
config.php
<?php
$CONFIG = array (
'instanceid' => '<id>',
'passwordsalt' => '<salt>',
'secret' => '<secret>',
'trusted_proxies' => '<proxy ip>',
'trusted_domains' =>
array (
0 => 'nextcloud.example.com',
1 => '<proxy ip>',
),
'datadirectory' => '/ncdata',
'dbtype' => 'mysql',
'version' => '<nextcloud version>',
'overwritehost' => 'nextcloud.example.com',
'overwriteprotocol' => 'https',
'overwritewebroot' => '/',
'overwritecondaddr' => '^16\.17\.17\.18', #proxy ip in regex form
'overwrite.cli.url' => 'https://nextcloud.example.com',
'dbname' => 'nextcloud',
'dbhost' => 'localhost:/mysql/mysql.sock',
'dbport' => '',
'dbtableprefix' => 'oc_',
'dbuser' => '<db user>',
'dbpassword' => '<db password>',
'installed' => true,
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '/redis/redis.sock',
'port' => 0,
),
'maintenance' => false,
);
Edit the crontab for the www user. crontab -u www -e
*/15 * * * * php-7.2 -f /var/www/nextcloud/cron.php
*/30 * * * * /usr/local/bin/php-7.2 -f /var/www/nextcloud/occ files:scan --all
php72-fpm bug credits: https://dev.to/nabbisen/fixing-php72fpm-on-openbsd-64-f0f
mkdir /etc/php-fpm.d
cat <<EOF>/etc/php-fpm.d/www.conf
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
[www]
user = www
group = www
listen = /var/www/run/php-fpm.sock
listen.owner = www
listen.group = www
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chroot = /var/www
EOF
su -m www -c 'php-7.2 /var/www/nextcloud/occ maintenance:mode --on'
su -m www -c 'php-7.2 /var/www/nextcloud/occ db:convert-filecache-bigint'
su -m www -c 'php-7.2 /var/www/nextcloud/occ maintenance:mode --off'