音乐服务器 linux,在Ubuntu/Debian/CentOS上安装Koel以配置个人音乐流媒体服务器

本文介绍安装和使用Koel在Ubuntu/Debian/CentOS/Fedora上配置个人音乐流媒体服务器。Koel是使用Vue和Laravel PHP Framework编写的开源、基于Web的简单个人音频流服务,面向Web开发人员,它采用了现代Web技术,例如CSS网格、音频和拖放API等等。

b1cf0f97cff0601974d079dea4d9c1e8.png

步骤1:安装数据库服务器

我们将专注于使用MariaDB数据库服务器,参考:

运行数据库服务后,请创建数据库,该服务的用户,然后为该用户授予权限:

$ mysql -u root -p

CREATE DATABASE koel DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

CREATE USER 'koel'@'localhost' IDENTIFIED BY 'k03lDBP@s3';

GRANT ALL PRIVILEGES ON koel.* TO 'koel'@'localhost' WITH GRANT OPTION;

EXIT;

步骤2:安装PHP服务器组件

在此步骤中,我们将安装PHP、Composer和Nginx httpd服务器。

针对Debian/Ubuntu服务器:

sudo apt -y install git curl g++ nginx

sudo apt -y install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

针对CentOS 7服务器:

sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

sudo yum -y install git wget curl epel-release yum-utils libpng-devel

sudo yum-config-manager --disable remi-php54

sudo yum-config-manager --enable remi-php73

sudo yum -y install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json

针对CentOS 8服务器:

sudo dnf -y install git wget curl yum-utils

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

dnf module reset php

sudo dnf module install php:remi-7.3

sudo yum -y install wget php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}

步骤3:安装Node.js、yarn、Composer

1、安装Nodejs

针对Ubuntu/Debian服务器:

sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

sudo apt update

sudo apt -y install nodejs

针对CentOS服务器:

sudo curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -

sudo yum -y install nodejs

2、安装yarn

针对Ubuntu/Debian服务器:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn

针对CentOS服务器:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

sudo yum -y install yarn

3、安装Composer

sudo su -

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

exit

通过查询版本来验证安装:

$ composer  --version

Composer version 1.9.3

步骤4:安装Koel个人音乐流媒体服务器

安装构建依赖项:

针对Ubuntu/Debian服务器:

$  sudo apt install -y build-essential libpng-dev gcc make ffmpeg

针对CentOS服务器:

$ sudo yum -y install epel-release

$ sudo yum group install "Development Tools"

$ sudo yum -y install libpng-devel

克隆koel项目:

git clone https://github.com/phanan/koel.git

cd koel

npm install

npm audit fix

composer install

安装输出信息如下:

7939dccb37ce848747f13530c3afd300.png

编辑.env文件,进行必要的配置更改,设置数据库,请根据自身的数据进行更改:

$ vim .envvim .env

....

# Database connection name, which corresponds to the database driver.

DB_CONNECTION=mysql

DB_DATABASE=koel

DB_USERNAME=koel

DB_PASSWORD='k03lDBP@s3'

# Credentials and other info to be used when Koel is installed in non-interactive mode

# (php artisan koel:init --no-interaction)

# By default (interactive mode), Koel will still prompt for these information during installation,

# but provide the values here as the defaults (except ADMIN_PASSWORD, for security reason).

ADMIN_NAME="Koel Admin"

ADMIN_EMAIL=249562751@qq.com

ADMIN_PASSWORD=Str0ngPassw0rd

# The memory limit, in MB, used by the scanning process.

# For example, if you want to set a memory limit of 2048MB, enter "2048" (without

# quotes) here.

MEMORY_LIMIT=512

The full path of ffmpeg binary.

FFMPEG_PATH=/usr/bin/ffmpeg

然后初始化数据库,然后开始为站点提供服务:

$ php artisan koel:init --no-interaction

$ php artisan serve

Laravel development server started:

这将仅允许来自本地主机的连接,如果想接受来自其他主机的连接,请通过提供‘host’选项来启动服务器:

$ php artisan serve --host 0.0.0.0

步骤5:配置Nginx

为了获得最佳性能,需要使用Apache或Nginx网络服务器设置生产版本,使用以下命令安装nginx。

针对Debian/Ubuntu服务器:

$ sudo apt -y install nginx php-fpm

$ sudo systemctl enable --now nginx

针对CentOS/Debian服务器:

$ sudo yum -y install nginx

$ sudo systemctl enable --now nginx

$ sudo firewall-cmd --add-service={http,https} --permanent

$ sudo firewall-cmd --reload

将koel专案资料夹移至/var/www/html目录:

sudo mv koel /var/www/html

然后设置权限。

针对Debian/Ubuntu服务器:

$ sudo chown -R www-data:www-data /var/www/html/koel

针对CentOS服务器:

$ sudo chown -R apache:apache /var/www/html/koel

配置Nginx:

$ sudo vim /etc/nginx/conf.d/koel.conf

在下面粘贴并修改:

server {

listen          *:80;

server_name     koel.example.com;

root            /var/www/html/koel;

index           index.php;

gzip            on;

gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;

gzip_comp_level  9;

# Whitelist only index.php, robots.txt, and some special routes

if ($request_uri !~ ^/$|index\.php|robots\.txt|(public|api)/|remote|api-docs|sw\.js) {

return 404;

}

location /media/ {

internal;

alias       $upstream_http_x_media_root;

access_log /var/log/nginx/koel.access.log;

error_log  /var/log/nginx/koel.error.log;

}

location / {

try_files   $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

try_files $uri $uri/ /index.php?$args;

fastcgi_param     PATH_INFO $fastcgi_path_info;

fastcgi_param     PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param     SCRIPT_FILENAME $document_root$fastcgi_script_name;

#fastcgi_pass              127.0.0.1:9000;

fastcgi_pass               unix:/run/php/php7.2-fpm.sock;

fastcgi_index             index.php;

fastcgi_split_path_info   ^(.+\.php)(/.+)$;

fastcgi_intercept_errors  on;

include                   fastcgi_params;

}

}

检查nginx配置是否存在语法错误:

$ sudo nginx  -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

重新启动nginx:

sudo systemctl restart nginx

配置到这里,就可以使用koel.example.com来访问Koel控制中心了,至此,配置Koel个人音乐流媒体服务器完成。

相关主题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值