From scratch to build the back-end DPlayer

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/Yuudachi/article/details/101612138

Preparing the Environment

A server or virtual machine (I use the CentOS7)

Virtual machine installation CentOS7 Tutorial: https: //blog.csdn.net/babyxue/article/details/80970526

Npm and environmental needs Nodejs

wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz
x d-node-linux-v10.13.0 x64.tar.xz
tar -xf node-v10 .13.0-linux-x64.tar
ln -s ~ / node-v10.13.0-linux-x64 / bin / node / usr / bin / node
ln -s ~ / node-v10.13.0-linux-x64 / bin / Elevation / usr / bin / above sea level

After installation can be viewed by npm -v and node -v whether the installation is successful

After the download is complete remember to add npm mirror or else will be very slow to download (here we use Taobao Mirror)

npm config set registry https://registry.npm.taobao.org

After the configuration can be verified by successful in the following manner

npm config get registry

Specific operations

step one

Download Docker

yum install docker

Docker's startup, shutdown and restart

Start systemctl start docker
close systemctl stop docker
restart systemctl restart docker

After downloading the configuration Docker Docker remember mirroring prevent the download speed is too slow (here we use Ali's image)

we /etc/docker/daemon.json

Modify the original contents of the file to the following (note that English double-quotes)

{
“registry-mirrors”: [“https://jzngeu7d.mirror.aliyuncs.com”]
}

After modification restart Docker

Step Two

Installation Docker Compose

curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

Docker Compose permission to otherwise insufficient permission errors will be reported

chmod +x /usr/local/bin/docker-compose

Step Three

Install git

yum install -y git

Pulling DPlayer source

git clone https://github.com/MoePlayer/DPlayer-node.git

Step Four

In the New mirroring step may report npm error error or other mistake
my mistake was npm ERR request to https://registry.npmjs.org/ngx-pagination failed, reason :! Getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs .org: 443

Solution

config SET Registry http://registry.npmjs.org/ NPM
NPM-config SET strict SSL to false
edit ~ / .npmrc added the following content
registry = https://registry.npm.taobao.org

Reference link: https: //blog.csdn.net/yypsober/article/details/51906616

Enter DPlayer-node directory

cd DPlayer-node

New Mirror

docker-compose build

And pulling the other background image

docker-compose up -d

At this point api address is http: // ip: 1207, and the log data stored in the / root / dplayer folder.

Of course, if you want other ports, or modify storage folder path, before you create a new image above, make the following operations:

#编辑DPlayer-node文件夹的docker-compose.yml文件,部分修改如下
mongo:
  volumes:
      - ~/dplayer/db:/data/db  #数据库存放文件夹,~/dplayer/db为映射在外部的路径,自行修改,
web:
  ports:
    - 1207:1207  #api映射到外部的端口,将前面的1207修改成你想要的即可
  volumes:
    - ~/dplayer/logs:/usr/src/app/logs  #同数据库操作
    - ~/dplayer/pm2logs:/root/.pm2/logs  #同上

Reference address: https: //www.moerats.com/archives/838/

Thus far DPlayer background build basic end! ! ! !

Guess you like

Origin blog.csdn.net/Yuudachi/article/details/101612138