之前用的live2d用不了了,本地搭建一个,不被卡脖子。

拉取live2d代码,将代码放到nginx的网站目录下,便于nginx和php都能访问到

git clone https://github.com/fghrsh/live2d_api.git

修改文件夹名称

mv live2d_api live2d

由于我这里博客都是使用docker-compose部署的,所以live2d也使用docker-compose搭建
docker-compose.yaml文件增加配置

  live2d:
    image: php:8-fpm
    networks:
      halo_network:
    volumes:
      - ./nginx/webroot/:/var/www/html

nginx增加配置

location ^~ /live2d/ {
     	 root '/usr/share/nginx/html/';
         location ~ \.php$ {
            root /var/www/html;
            fastcgi_pass live2d:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            include  fastcgi_params;
          }
     }

测试是否正常
https://www.summerpond.cn/live2d/get/?id=1-23
最后修改主题文件,路径source/lib/live2d/autoload.js

live2d_settings['modelAPI'] = "https://www.summerpond.cn/live2d/"