Debian 11(bullseye) 安装Nextcloud,使用PostgreSQL

Debian11 安装 NextCloud 使用 PostgreSQL

硬件

本次使用的是虚拟机,主要操作是一样的

CPU:双核

内存:1G

硬盘:20G,数据放在另外的硬盘中

IP:10.10.10.210

安装系统

安装 Debian 11 标准环境,没有桌面图形,如有网络也可以使用网络安装包

https://mirrors.tuna.tsinghua.edu.cn/debian-cd/current-live/amd64/iso-hybrid/debian-live-11.2.0-amd64-standard.iso

设置系统

更新源

cp /etc/apt/sources.list /etc/apt/sources.list.bak
rm -rf /etc/apt/sources.list
touch /etc/apt/sources.list
nano /etc/apt/sources.list
​
# 添加以下内容到文件中后保存
​
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
​
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
​
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

更新系统

apt update
apt upgrade

安装一些工具

apt install vim net-tools htop zip unzip -y

可选的一些玩意儿,不安也没事儿

apt install neofetch cmatrix zhcon nfs-common

固定系统网络 IP 地址

 vim /etc/network/interfaces
 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
​
source /etc/network/interfaces.d/*
​
# The loopback network interface
auto lo
iface lo inet loopback
​
# The primary network interface
allow-hotplug ens18
# iface ens18 inet dhcp
​
iface ens18 inet static
address 10.10.10.210/24
gateway 10.10.10.1
​
# 修改后保存退出
​
# 重启网络,修改错误时有可能网络无法启动,所以要小心检查配置没问题再操作
ifdown ens18 && ifup ens18 或 systemctl restart networking.service && ifup ens18

设置存放数据的位置

为数据库及 NextCloud 存放文件准备目录,数据库的目录在初始化数据库时由系统自动建立

实际可自行修改,只要后面对应修改就可以

mkdir /Storage
chmod -R 777 /Storage

设置开机自动启动的脚本

为了后面 PostgreSQL 服务在每次开机后自动启动服务使用

cat /lib/systemd/system/rc-local.service    # 查看该文件中 rc.local 文件所在的位置,一般为 /etc/rc.local
ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/ # 创建一个服务的软链接
touch /etc/rc.local
chmod 755 /etc/rc.local
vim /etc/rc.local   #编辑这个新文件,并写入以下内容
​
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
​
#要执行的脚本一定要写在这个 exit 0 的前面位置
exit 0
​
# 保存文档后,需要重启一下服务,以后再开机后就可以自动运行想要的脚本内容了
systemctl restart rc-local.service  #没反应即为正常,如有脚本语法错误,会有错误提示
​

安装 PostgreSQL 数据库服务

下载最新版的源码

wget https://mirrors.tuna.tsinghua.edu.cn/postgresql/latest/postgresql-14.1.tar.gz

安装所需要的系统依赖组件

正常只需要有这两个依赖就可以完成安装,在 configure 阶段如还有缺少的依赖会有提示,到时直接安装即可

apt install libreadline-dev zlib1g-dev -y

编译安装

整个过程会需要一些时间,不过相对还是很快的

tar xzvf postgresql-14.1.tar.gz
cd postgresql-14.1
./configure --prefix=/usr/local/postgresql  # 将服务程序安装在 /usr/local/postgres 目录中
# 如在未有报错停止,则继续往下操作,如有问题,则处理到没有问题后再继续操作
make -j2    # 多线程,不要超过CPU的最大线程
make install

初始化数据文件

# 先创建以后要使用服务的普通系统用户,名字随便,能记住就行
adduser postgres
​
su - postgres
vim .profile
# 在文件最后添加以下内容,为以后操作方便
export PGHOME=/usr/local/postgresql
export PGDATA=/Storage/CloudPGDATA
export PGLOG=/Storage/CloudPGLOG.log
PATH=$PATH:$PGHOME/bin
# 保存退出
​
source .profile # 更新一下环境变量
initdb -E utf8 -D $PGDATA -U postgres -W
# 因为不需要对外提供服务,所以不需要修改配置,仅本地可访问即可

添加开始自动启动服务

su - postgres
touch runCloudPGDATA.sh stopCloudPGDATA.sh  # 两个文件需要分别写入指定内容
​
vim runPGDATA.sh
pg_ctl -D $PGDATA -l $PGLOG start
​
vim stopPGDATA.sh
pg_ctl -D $PGDATA -l $PGLOG stop
​
# 保存退出后,可以先运行试试
chmod a+x runCloudPGDATA.sh stopCloudPGDATA.sh
​
exit    # 回到 root 用户
vim /etc/rc.local   # 要在 exit 0 的前面添加以下内容
su - postgres -c /home/postgres/runCloudPGDATA.sh
​
# 保存退出后看是否有错误信息,无错误信息则代表成功
systemctl restart rc-local.service

安装 PHP 环境

这个比较简单,为了省事儿,就不编译了,直接使用源中的版本就可以,现在版本是 PHP7.4

apt-get update
apt-get install -y php7.4
# 注意:必须要一步步的安装,如一下都安装上,会没有apache的服务,就无法提供网页服务了
apt-get install -y php7.4-dev
apt-get install -y php-pear
apt-get install -y php7.4-fpm php-pgsql php-sqlite3 php7.4-mysql php7.4-curl php7.4-json php7.4-mbstring php7.4-xml php7.4-intl php7.4-gd php7.4-gmp php7.4-bcmath php-imagick php7.4-xml php7.4-zip

需要注意的是,PHP 里的数据库组件,装了哪个,NextCloud 就会支持哪种数据库

组件名说明
php-pgsqlPostgreSQL 支持,本次使用这个数据库
php7.4-mysqlMySQL /MarieDB 支持
php-sqlite3Sqlite 支持

安装 NextCloud

下载文件

wget https://download.nextcloud.com/server/releases/nextcloud-23.0.0.zip

安装文件

unzip nextcloud-23.0.0.zip
mv nextcloud /var/www/html/
chown -R www-data:www-data /var/www/html/nextcloud
# 此时浏览器输入 http://10.10.10.210:8080/nextcloud 就可以进入图型安装页面了
mkdir /Storage/CloudFiles
chown -R www-data:www-data /Storage/CloudFiles
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值