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 目录,可以扫出新增音乐
分类: 教程 标签: 搭建教程Koel音乐平台

评论

暂无评论数据

暂无评论数据

目录