# cd /usr/ports/databases/postgresql16-server/
# make install clean
配置:
root@ykla:~ # service postgresql enable
postgresql enabled in /etc/rc.conf
初始化数据库
root@ykla:~ # service 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 this locale configuration:
provider: libc
LC_COLLATE: C
LC_CTYPE: C.UTF-8
LC_MESSAGES: C.UTF-8
LC_MONETARY: C.UTF-8
LC_NUMERIC: C.UTF-8
LC_TIME: C.UTF-8
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /var/db/postgres/data16 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
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
initdb: hint: 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/data16 -l logfile start
root@ykla:/usr/ports/www/nextcloud # su - postgres #切换到数据库用户
$ /usr/local/bin/pg_ctl -D /var/db/postgres/data16/ -l logfile start # 初始化
waiting for server to start.... done
server started
$ psql -Upostgres # 进入命令模式
psql (16.7)
Type "help" for help.
postgres=# create user nextcloud; # 创建所需用户
CREATE ROLE
postgres=# \password nextcloud # 创建用户 nextcloud 密码,注意斜杠要输入:\
Enter new password for user "nextcloud": # 此处输入密码,密码不会显示到屏幕上,也不是 *,就是空的,下同
Enter it again: # 再次重复输入上面密码
postgres=# create database nextcloud owner=nextcloud; # 创建所需数据库的属主
CREATE DATABASE
postgres-# \q # 退出,注意斜杠要输入:\
root@ykla:~ # php -v
PHP 8.3.17 (cli) (built: Feb 15 2025 01:11:28) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.17, Copyright (c) Zend Technologies
with Zend OPcache v8.3.17, Copyright (c), by Zend Technologies
# pkg install mod_php83
# service php_fpm enable
# service php_fpm start
基于 Apache
# pkg install apache24
或者
# cd /usr/ports/www/apache24/
# make install clean
配置服务:
# service apache24 enable
查看 Apache 配置方法
root@ykla:/usr/ports/www/nextcloud # pkg info -D mod_php83
root@ykla:~ # pkg info -D mod_php83
mod_php83-8.4.4_1:
On install:
******************************************************************************
Consider switching to php-fpm and mod_fast_cgi as per Apache httpd project
recommendation. See https://cwiki.apache.org/confluence/display/HTTPD/PHP-FPM
建议根据 Apache httpd 项目的推荐,切换到 php-fpm 和 mod_fast_cgi。详情请见 https://cwiki.apache.org/confluence/display/HTTPD/PHP-FPM
******************************************************************************
If you are building PHP-based ports in poudriere(8) or Synth with ZTS enabled,
add WITH_MPM=event to /etc/make.conf to prevent build failures.
如果你在 poudriere(8) 或 Synth 中构建启用了 ZTS 的 PHP 基础端口,请将 WITH_MPM=event 添加到 /etc/make.conf,以防止构建失败。
******************************************************************************
Make sure index.php is part of your DirectoryIndex.
确保 index.php 是 DirectoryIndex 的一部分。
You should add the following to your Apache configuration file:
你应该将以下内容添加到你的 Apache 配置文件中:
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
******************************************************************************
root@ykla:~ # pkg info -D nextcloud-php83
nextcloud-php83-30.0.6:
On install:
/!\ The FreeBSD package REQUIRES the apps_paths configuration as /!\
/!\ seen in config/config.sample.php to function /!\
/!\ FreeBSD 包需要配置 apps_paths,如 config/config.sample.php 中所示才能正常工作 /!\
Please note that everything has been installed in /usr/local/www/nextcloud.
请注意,所有文件已安装在 /usr/local/www/nextcloud 中。
You will probably want to add an alias to your httpd.conf file,
something like this:
你可能需要在 httpd.conf 文件中添加一个别名,类似如下:
Alias /nextcloud /usr/local/www/nextcloud
AcceptPathInfo On
<Directory /usr/local/www/nextcloud>
AllowOverride All
Require all granted
</Directory>
And restart Apache. Nextcloud will start the bundled installer on first
access. Once the bundled installer finishes, further configuration can
be done via 'Settings', 'Administration'. Additional configuration
options are available in
然后重启 Apache。Nextcloud 会在首次访问时启动捆绑的安装程序。安装程序完成后,可以通过 'Settings' 和 'Administration' 进行进一步配置。更多配置选项可以在以下位置找到:
/usr/local/www/nextcloud/config/config.php
You can find annotated configuration options in config.documented.php
in the same directory. Nextcloud's configuration documentation is at
你可以在同一目录下的 config.documented.php 中找到带注释的配置选项。Nextcloud 的配置文档请参考:
https://docs.nextcloud.com/server/stable/admin_manual/configuration_server
The caching options require additional Nextcloud configuration.
缓存选项需要额外的 Nextcloud 配置。
On upgrade:
After a version migration you should upgrade your nextcloud instance
using command line:
升级后,你应该使用命令行升级你的 nextcloud 实例:
occ upgrade
Merge any changes to /usr/local/www/nextcloud/.htaccess.dist into .htaccess (above the
'#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####' divider if it exists)
and update the dynamic part of the file using the commandline:
将 /usr/local/www/nextcloud/.htaccess.dist 中的任何更改合并到 .htaccess 文件中(如果存在的话,请合并到 '#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####' 分隔符上方),并使用命令行更新文件的动态部分:
occ maintenance:update:htaccess
As of Nextcloud 27.1.0 the recommended PHP version is 8.2.
Nextcloud 27.1.0,推荐使用 PHP 8.2 版本。
编辑 /usr/local/etc/apache24/httpd.conf,加入:
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
Alias /nextcloud /usr/local/www/nextcloud
AcceptPathInfo On
<Directory /usr/local/www/nextcloud>
AllowOverride All
Require all granted
</Directory>