Anki: 自建服务器

2020-08-31

安装步骤

  • python3.6 (支持sqlite3)
  • 安装pyaudio
  • clone anki-sync-server
  • nginx 配置
  • client 配置
python3.6
yum install sqlite-devel
wget http://xx.com/me/software/Python-3.6.7.tgz
安装pyaudio
wget http://portaudio.com/archives/pa_stable_v190600_20161030.tgz
tar  -zxvf pa_stable_v190600_20161030.tgz
cd  portaudio
./configure  &&  make
sudo make install
vim /etc/ld.so.conf.d/portaudio.conf <<EOF
/usr/local/lib
EOF
sudo ldconfig -v

sudo pip3 install pyaudio

anki-sync-server
git clone https://github.com/dae/anki && cd anki
pip3 install -r requirements.txt
useradd -d /home/anki -m anki
su -l anki
git clone --recursive https://github.com/tsudoko/anki-sync-server
cd anki-sync-server
python3 ankisyncctl.py adduser username # 添加用户名
python3 -m ankisyncd # 启动服务

ankisyncd.conf 配置文件

nginx配置
server {
    listen 27701; 
    server_name 0.0.0.0;

    location / {
    	rewrite ^/5sync/(.*)$ /sync/$1 last;
    	rewrite ^/5msync/(.*)$ /msync/$1 last;
	    proxy_pass http://127.0.0.1:27702/;
	    proxy_set_header HOST $host;
	    proxy_set_header X-Real-IP $remote_addr;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}
client 配置
  • 打开anki客户端 -> Tools -> Add ons -> View files
  • addons21 目录下新建目录 ankisyncd -> __init__py 如下图
cat __init__py <<EOF
import anki.sync
addr = "http://xx.xx.xx.xx:27701/"
anki.sync.SYNC_BASE = addr + "%s"
EOF

No. 127: ankisyncd – A Custom Sync Server for Anki 2.1 | Gene Dan’s Blog

consul 使用教程