【超火】吐血推荐 docker 搭建Koel音乐平台详细步骤

187次阅读
没有评论

共计 4111 个字符,预计需要花费 11 分钟才能阅读完成。

Koel 是一个自己托管自己的音乐的平台,官网 https://koel.dev/

这是我搭建的效果:

音乐是论坛分享的 douban250 无损 flac:

https://www.aliyundrive.com/s/xuLCHkV97ML/folder/60dbe0c6f4f846a765ca403e982fa00b2849bd46

安装过程,主要使用 docker 来简化安装,网上有的帖子说 docker 安装的性能差,我分析了一下并没有这回事。

只是说因为要处理音乐上传 / 下载,这个系统的压力主要有:占用的磁盘空间比较大(1 个音乐 30M),还有占用内存也是比较多,所以 1C1G 的小鸡搭建不出来。

我用的是 RN 的,4C4G 的年付套餐,当然 3H3G 也行,

4C4G:http://click.idcpay.me/rn-4c-4g
3C3G:  http://click.idcpay.me/rn-3c-3g

  1. # 1 准备步骤,安装 docker
  2. yum -y install docker
  3. systemctl enable docker
  4. # 2 安装 docker-compose
  5. sudo curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
  6. sudo chmod +x /usr/local/bin/docker-compose
  7. # 3 新建一个 koel 目录备用
  8. mkdir koel
  9. cd koel
  10. # 4 新建一个目录存放文件
  11. mkdir /opt/music
  12. /opt/music/covers
  13. # 5 准备你的域名 a.com
  14. # 6 准备 docker-compose.yml 文件
  15. ######################################
  16. # docker-compose.yml 可以修改你的数据库密码
  17. version: ‘3.5’
  18. services:
  19.   koel:
  20.     image: hyzual/koel
  21.     depends_on:
  22.       – koel-database
  23.     ports:
  24.       – “127.0.0.1:2077:80”
  25.     environment:
  26.       FORCE_HTTPS: 1
  27.       MEMORY_LIMIT: 512
  28.       DB_CONNECTION: mysql
  29.       DB_HOST: koel-database
  30.       DB_USERNAME: koel
  31.       DB_PASSWORD: Koko0202#1234
  32.       DB_DATABASE: koel
  33.     volumes:
  34.       – /opt/music:/music
  35.       – /opt/music/covers:/var/www/html/public/img/covers
  36.     restart: unless-stopped
  37.   koel-database:
  38.     image: mysql/mysql-server:5.7
  39.     environment:
  40.       MYSQL_ROOT_PASSWORD: Koko0202#1234
  41.       MYSQL_DATABASE: koel
  42.       MYSQL_USER: koel
  43.       MYSQL_PASSWORD: Koko0202#1234
  44.     volumes:
  45.       – koel_db:/var/lib/mysql
  46.     restart: unless-stopped
  47. volumes:
  48.   koel_db:
  49.     driver: local
  50.   koel_music:
  51.     driver: local
  52.   koel_covers:
  53.     driver: local
  54. #docker-compose.yml 文件结束
  55. ###################
  56. # 7 启动 docker
  57. docker-compose up -d
  58. 看到都成功了,即可
  59. # 8 安装 nginx 和 python-certbot-nginx
  60. python-certbot-nginx 是维护 lets’ encrypt 证书用的
  61. yum -y install nginx
  62. yum install python-certbot-nginx
  63. #9 初始化 koel
  64. docker-compose exec k2_koel_1 php artisan koel:init
  65. docker exec -it k2_koel_1 php artisan koel:admin:change-password
  66. k2_koel_1 是 koel 容器名字,根据你情况来。默认管理员是:admin@koel.dev
  67. # 10 处理 nginx 和 https 问题
  68. 新建 nginx 配置文件只带 http 80 端口版本的,命名为 koel.conf 放在 /etc/nginx/conf.d/
  69. #http 版本的 nginx 配置文件
  70. server {
  71.      listen 80;
  72.      listen [::]:80;
  73.      server_name a.com;
  74.      location / {
  75.                  proxy_pass http://127.0.0.1:2207;
  76.                  proxy_set_header X-Forwarded-Host $server_name;
  77.                  proxy_set_header X-Forwarded-Server $host;
  78.                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  79.                  proxy_set_header   Host $host;
  80.                  proxy_set_header   X-Real-IP $remote_addr;
  81.                  proxy_set_header X-Forwarded-Proto https;
  82.                  # Not sure if these next two lines are needed. I did not remove them as
  83.                  # I did not want risk breaking my working configuration. Just remember
  84.                  # to replace “koel.domain.tld” with your instance’s domain.
  85.                  sub_filter “http://koel.domain.tld” “http://music.idcpay.me”;
  86.                  sub_filter_once off;
  87.      }
  88.   }
  89. 启动 nginx
  90. 再启动 cerbot
  91. certbot certonly –nginx
  92. 生成 key/pem 文件后,重新设置 https 版本配置文件
  93. server {
  94.      listen 80;
  95.      listen [::]:80;
  96.      listen 443 ssl;
  97.      server_name a.com;
  98.      ssl_certificate /etc/letsencrypt/live/music.idcpay.me/fullchain.pem;
  99.      ssl_certificate_key /etc/letsencrypt/live/music.idcpay.me/privkey.pem;
  100.      location / {
  101.                  proxy_pass http://127.0.0.1:2077;
  102.                  # 如果是本机直接复制就行,如果是别的机器,记得换成你的 ip 地址
  103.                  proxy_set_header X-Forwarded-Host $server_name;
  104.                  proxy_set_header X-Forwarded-Server $host;
  105.                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  106.                  proxy_set_header   Host $host;
  107.                  proxy_set_header   X-Real-IP $remote_addr;
  108.                  proxy_set_header X-Forwarded-Proto https;
  109.                  # Not sure if these next two lines are needed. I did not remove them as
  110.                  # I did not want risk breaking my working configuration. Just remember
  111.                  # to replace “koel.domain.tld” with your instance’s domain.
  112.                  sub_filter “http://koel.domain.tld” “https://music.idcpay.me”;
  113.                  sub_filter_once off;
  114.      }
  115. }
  116. 运行:
  117. nginx -s reload
  118. 如果没有错误,就可以输入 https://a.com 欣赏你的音乐了。
  119. 其他资源:
  120. 可以搭建 Koel 的便宜主机:
  121. 4C4G 购买入口:http://click.idcpay.me/rn-4c-4g
  122. 3C3G 购买入口:  http://click.idcpay.me/rn-3c-3g
  123. 阿里云盘音乐豆瓣 250 无损 flac:
  124. https://www.aliyundrive.com/s/xuLCHkV97ML/folder/60dbe0c6f4f846a765ca403e982fa00b2849bd46
  125. linux 环境下载阿里云盘的客户端:
  126. https://github.com/tickstep/aliyunpan
  127. 不需要下载再上传文件
  128. 音乐管理:
  129. 把 mp3 flac 等音乐文件放到虚拟主机的这里:
  130. /opt/music
  131. 在 Koel 面板上,扫描:
  132. /music 目录,可以扫出新增音乐
正文完
 
阿里郎
版权声明:本站原创文章,由 阿里郎 2021-12-23发表,共计4111字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
国外主机测评
国外主机测评
专注于主机测评,主机推荐,VPS测评,VPS推荐,VPS教程,服务器推荐,Linux教程,服务器教程
阅读量
180602
评论数
23



hostkvm优惠促销活动
评论(没有评论)
衡天云优惠活动