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 准备步骤,安装docker
- yum -y install docker
- systemctl enable docker
- # 2 安装docker-compose
- 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
- sudo chmod +x /usr/local/bin/docker-compose
- # 3 新建一个 koel 目录备用
- mkdir koel
- cd koel
- # 4 新建一个目录存放文件
- mkdir /opt/music
- /opt/music/covers
- # 5 准备你的域名 a.com
- # 6 准备 docker-compose.yml 文件
- ######################################
- # docker-compose.yml 可以修改你的数据库密码
- version: ‘3.5’
- services:
- koel:
- image: hyzual/koel
- depends_on:
- – koel-database
- ports:
- – “127.0.0.1:2077:80”
- environment:
- FORCE_HTTPS: 1
- MEMORY_LIMIT: 512
- DB_CONNECTION: mysql
- DB_HOST: koel-database
- DB_USERNAME: koel
- DB_PASSWORD: Koko0202#1234
- DB_DATABASE: koel
- volumes:
- – /opt/music:/music
- – /opt/music/covers:/var/www/html/public/img/covers
- restart: unless-stopped
- koel-database:
- image: mysql/mysql-server:5.7
- environment:
- MYSQL_ROOT_PASSWORD: Koko0202#1234
- MYSQL_DATABASE: koel
- MYSQL_USER: koel
- MYSQL_PASSWORD: Koko0202#1234
- volumes:
- – koel_db:/var/lib/mysql
- restart: unless-stopped
- volumes:
- koel_db:
- driver: local
- koel_music:
- driver: local
- koel_covers:
- driver: local
- #docker-compose.yml 文件结束
- ###################
- # 7 启动docker
- docker-compose up -d
- 看到都成功了,即可
- # 8 安装nginx 和 python-certbot-nginx
- python-certbot-nginx 是维护lets’ encrypt 证书用的
- yum -y install nginx
- yum install python-certbot-nginx
- #9 初始化koel
- docker-compose exec k2_koel_1 php artisan koel:init
- docker exec -it k2_koel_1 php artisan koel:admin:change-password
- k2_koel_1 是koel 容器名字,根据你情况来。默认管理员是:admin@koel.dev
- # 10 处理nginx 和 https问题
- 新建nginx配置文件只带http 80端口版本的,命名为 koel.conf 放在 /etc/nginx/conf.d/
- #http版本的nginx配置文件
- server {
- listen 80;
- listen [::]:80;
- server_name a.com;
- location / {
- proxy_pass http://127.0.0.1:2207;
- proxy_set_header X-Forwarded-Host $server_name;
- proxy_set_header X-Forwarded-Server $host;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-Proto https;
- # Not sure if these next two lines are needed. I did not remove them as
- # I did not want risk breaking my working configuration. Just remember
- # to replace “koel.domain.tld” with your instance’s domain.
- sub_filter “http://koel.domain.tld” “http://music.idcpay.me”;
- sub_filter_once off;
- }
- }
- 启动nginx
- 再启动cerbot
- certbot certonly –nginx
- 生成key/pem文件后,重新设置https版本配置文件
- server {
- listen 80;
- listen [::]:80;
- listen 443 ssl;
- server_name a.com;
- ssl_certificate /etc/letsencrypt/live/music.idcpay.me/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/music.idcpay.me/privkey.pem;
- location / {
- proxy_pass http://127.0.0.1:2077;
- # 如果是本机直接复制就行,如果是别的机器,记得换成你的ip地址
- proxy_set_header X-Forwarded-Host $server_name;
- proxy_set_header X-Forwarded-Server $host;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-Proto https;
- # Not sure if these next two lines are needed. I did not remove them as
- # I did not want risk breaking my working configuration. Just remember
- # to replace “koel.domain.tld” with your instance’s domain.
- sub_filter “http://koel.domain.tld” “https://music.idcpay.me”;
- sub_filter_once off;
- }
- }
- 运行:
- nginx -s reload
- 如果没有错误,就可以输入 https://a.com 欣赏你的音乐了。
- 其他资源:
- 可以搭建Koel的便宜主机:
- 4C4G购买入口:http://click.idcpay.me/rn-4c-4g
- 3C3G购买入口: http://click.idcpay.me/rn-3c-3g
- 阿里云盘音乐豆瓣250无损flac:
- https://www.aliyundrive.com/s/xuLCHkV97ML/folder/60dbe0c6f4f846a765ca403e982fa00b2849bd46
- linux环境下载阿里云盘的客户端:
- https://github.com/tickstep/aliyunpan
- 不需要下载再上传文件
- 音乐管理:
- 把mp3 flac等音乐文件放到虚拟主机的这里:
- /opt/music
- 在Koel 面板上,扫描:
- /music 目录,可以扫出新增音乐
留言