您现在的位置是:首页> 网站开发

搭建私人通讯录/日历同步服务_使用cardDAV/calDAV服务

  • 6959人已阅读
  • 时间:2021-08-01 16:00:08
  • 分类:网站开发
  • 作者:祥哥

  1. 采用免费和开源的 CalDAV 和 CardDAV 服务器radicale。官方网址:https://radicale.org/

  2. 需要环境Python3以上

  3. 此次服务器环境:Centos7

  4. 可以使用客户端:支持 CardDAV-Sync-free-0.4.5DAVdroid(DAVx5)2.6.3

实践:

一、安装Python3

#安装依懒环境
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum -y install libffi-devel zlib1g-dev
yum install zlib* -y
#下载安装包,也可以去官网下载上传。官网地址:
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
#解压
tar -zxvf Python-3.9.6.tgz
#创建安装目录
mkdir /usr/local/python3
#安装
./configure --prefix=/usr/local/python3 --with-ssl
#第一个指定安装的路径
#第二个开启SSL,安装pip用到
make && make install
#软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
ln -s /usr/local/python3/bin/pip /usr/bin/pip

二、修改pip安装源

修改系统pip安装源

在家目录下新建.pip文件夹,进入文件夹新建文件pip.conf之后写入相应镜像网站地址

cd ~
mkdir .pip
cd .pip
vim pip.conf
#进入后添加以下内容,保存退出.
[global]
index-url = https://mirrors.aliyun.com/pypi/simple

三、安装radicale

python3 -m pip install --upgrade radicale

四、配置radicale

Radicale 尝试从/etc/radicale/config和加载配置文件

vi /etc/radicale/config
#config内容
[server]
#服务器IP配置选项(IPv4 和 IPv6)进行更改
hosts = 0.0.0.0:5232, [::]:5232
#最大并发数
max_connections = 20
# 最大文件100 Megabyte
max_content_length = 100000000
# 30 seconds
timeout = 30
[storage]
#数据存储在文件夹中
filesystem_folder = /home/radicale/collections
[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
# encryption method used in the htpasswd file
htpasswd_encryption = plain
# 密码输入错误延迟(秒)
delay = 120
#users内容
user1:password1
user2:password2

五、作为服务运行

#为Radicale服务创建用户和组。
useradd --system --user-group --shell /sbin/nologin radicale
#创建数据存放目录
mkdir -p /home/radicale/collections
#更改用户和所属组
chown -R radicale:radicale /home/radicale/collections
#禁止其它用户访问
chmod -R o= /home/radicale/collections

#创建文件/etc/systemd/system/radicale.service

[Unit]
Description=A simple CalDAV (calendar) and CardDAV (contact) server
After=network.target
Requires=network.target

[Service]
ExecStart=/usr/bin/env python3 -m radicale
Restart=on-failure
User=radicale
# Deny other users access to the calendar data
UMask=0027

[Install]
WantedBy=multi-user.target

要启用和管理服务运行:
# Enable the service
$ systemctl enable radicale
# Start the service
$ systemctl start radicale
# Check the status of the service
$ systemctl status radicale
# View all log messages
$ journalctl --unit radicale.service


上一篇:linux ACL 权限

下一篇:CentOS修改时区时间

Top