Radicale 部署

Radicale

  • Radicale is a small but powerful CalDAV (calendars, to-do lists) and CardDAV (contacts) server
  • Radicale是一个轻便的日程及任务管理程序,类似于iPhone、Outlook中的日程及任务程序

    https://github.com/Kozea/Radicale
    https://radicale.org/master.html

  • 很多人都在使用日程管理的软件,你可以直接借助软件来实现多端同步。我这边手机是iPhone,电脑是Windows,协同起来不是很方便,而我又不想重新弄个日程管理软件

  • 刚好我电脑上在用Thunderbird来管理邮件,它里面集成了日历、任务、通讯录这些模块。了解了一下,发现有一种CalDAV形式的日历程序可以在多用户端订阅,于似乎开始折腾Radicale
  • 这里简单讲一下在Windows以及VPS上部署Radicale服务

Windows

如果想在Windows上部署,非常简单,Radicale基于Python,只需配置好Python环境,然后运行,具体可以参考官方文档

  1. The first step is to install Python. Go to python.org and download the latest version of Python 3. Then run the installer. On the first window of the installer, check the "Add Python to PATH" box and click on "Install now".

  2. Launch a command prompt and type:

    python -m pip install --upgrade https://github.com/Kozea/Radicale/archive/master.tar.gz
    
    python -m radicale --storage-filesystem-folder=~/radicale/collections
    

    如果你想指定配置文件、存储路径来运行,可以采用如下的方式

    python -m radicale --config=D:\Development\Radicale\config --storage-filesystem-folder=D:\Development\Radicale\collections
    
  3. Open http://localhost:5232 in your browser! You can log in with any username and password.

VPS

  • 如果你有一台闲置的VPS或者远程服务器,那么你可以架设在上面,所有的过程和Windows基本相似
  • 前期我在Windows上搭建过,所有的数据和配置文件都已经有了,后面迁移到了VPS,这里简单记录下我的搭建过程

安装

  • 需要Python 3.7 以上
    python3 -m pip install --upgrade https://github.com/Kozea/Radicale/archive/master.tar.gz
    

配置文件

  • 我在配置文件中指定了用户、文件存储位置
  • 注意要放开VPS的端口,比如:sudo ufw allow 5232

    [server]
    # CalDAV server hostnames separated by a comma
    # IPv4 syntax: address:port
    # IPv6 syntax: [address]:port
    # For example: 0.0.0.0:9999, [::]:9999
    hosts = 0.0.0.0:5232
    
    # Max parallel connections
    max_connections = 8
    
    # Max size of request body (bytes)
    max_content_length = 100000000
    
    # Socket timeout (seconds)
    timeout = 30
    
    [auth]
    # Authentication method
    # Value: none | htpasswd | remote_user | http_x_remote_user
    type = htpasswd
    
    # Htpasswd filename
    #htpasswd_filename = /etc/radicale/users
    htpasswd_filename = /radicale/user
    
    # Htpasswd encryption method
    # Value: plain | bcrypt | md5
    # bcrypt requires the installation of radicale[bcrypt].
    htpasswd_encryption = plain
    
    # Incorrect authentication delay (seconds)
    #delay = 1
    
    [storage]
    # Storage backend
    # Value: multifilesystem | multifilesystem_nolock
    #type = multifilesystem
    
    # Folder for storing local collections, created if not present
    #filesystem_folder = /var/lib/radicale/collections
    
    filesystem_folder = /radicale/collections
    

上传文件

  • 如果有本地的collection文件夹user文件config文件
  • 可以直接上传到服务器
    # 解压
    unzip radicale.zip -d .
    
    # 赋予权限
    chmod -R 777 /radicale/
    

运行:简单命令行

  • 无日志
    python3 -m radicale --config=/radicale/config --storage-filesystem-folder=/radicale/collections
    
  • 显示日志,Debug
    python3 -m radicale --config=/radicale/config --storage-filesystem-folder=/radicale/collections --debug
    

运行:后台守护

  • 这里采用nohup来使得程序常驻后台
    # 运行
    nohup python3 -m radicale --config=/radicale/config --storage-filesystem-folder=/radicale/collections >> /dev/null 2>&1 &
    
    # List 列出程序
    ps -ef | grep radicale
    
    # Kill 结束程序
    ps aux | grep radicale | grep -v grep | awk '{print $2}' | xargs kill -15
    

运行:Systemd 后台

也可以采用官方推荐的systemd形式使其后台运行

  • 创建 Systemd 服务文件
    vim /etc/systemd/system/radicale.service
    
  • 在文件中插入以下内容
    [Unit]
    Description=A simple CalDAV (calendar) and CardDAV (contact) server
    After=network.target
    Requires=network.target
    
    [Service]
    ExecStart=/usr/local/bin/python3.7 -m radicale --config=/radicale/config --storage-filesystem-folder=/radicale/collections
    ExecStop=/bin/kill -s QUIT $MAINPID
    Restart=on-failure
    User=root
    
    # Deny other users access to the calendar data
    UMask=0027
    # Optional security settings
    PrivateTmp=true
    ProtectSystem=strict
    ProtectHome=true
    PrivateDevices=true
    ProtectKernelTunables=true
    ProtectKernelModules=true
    ProtectControlGroups=true
    NoNewPrivileges=true
    ReadWritePaths=/radicale/collections
    
    [Install]
    WantedBy=multi-user.target
    
  • 设置权限
    chmod 644 /etc/systemd/system/radicale.service
    
  • 启动 Radicale 服务及其他操作
    # Enable the service
    systemctl enable radicale
    
    # Start the service
    systemctl start radicale
    systemctl restart radicale
    
    # Check the status of the service
    systemctl status radicale
    
    # Stop the service
    systemctl stop radicale
    

SSL(可以不弄)

  • 如果不是https,那么无法在IOS上添加,账号验证会失败
  • 如果需要添加SSL,可以在宝塔中添加网站,添加域名,添加SSL,然后设置反代
  • 之后就可以使用https的形式来访问,可以使用ip:port或者域名

    1
    https://github.com/Kozea/Radicale/issues/936
    balki, commented on Apr 2, 2019
    If the server is not running https, it wont work on iphone/ios. ref: #870 (comment)
    2
    https://github.com/Kozea/Radicale/issues/870#issuecomment-458397475
    balki commented on Jan 29, 2019
    I was able to get it it working with iphone. As @mbiebl commented, the root cause is ios does not send credentials without ssl.

    Radicale_Reverse_proxy_Small.jpg

标题:Radicale 部署
链接:http://www.outblue.cc/343
来源:OutBlue Blog
说明:文章版权本站所有,欢迎转载分享,望能备注出处
THE END
分享
二维码
< <上一篇
下一篇>>