3.4 KiB
Installing Dragonfly CDN Server
This topic explains how to install the Dragonfly CDN server.
Context
Install CDN in one of the following ways:
- Deploying with Docker.
- Deploying with physical machines: Recommended for production usage.
Prerequisites
When deploying with Docker, the following conditions must be met.
| Required Software | Version Limit |
|---|---|
| Git | 1.9.1+ |
| Docker | 1.12.0+ |
When deploying with physical machines, the following conditions must be met.
| Required Software | Version Limit |
|---|---|
| Git | 1.9.1+ |
| Golang | 1.12.x |
| Nginx | 0.8+ |
Procedure - When Deploying with Docker
Get cdn image
You can get it from DockerHub directly.
-
Obtain the latest Docker image of the cdn.
docker pull d7yio/cdn
Or you can build your own cdn image.
-
Obtain the source code of Dragonfly.
git clone https://github.com/dragonflyoss/Dragonfly2.git -
Enter the project directory.
cd Dragonfly2 -
Build the Docker image.
TAG="1.0.0" make docker-build-cdn D7Y_VERSION=$TAG -
Obtain the latest Docker image ID of the cdn.
docker image ls | grep 'cdn' | awk '{print $3}' | head -n1
Start cdn
NOTE: Replace ${cdnDockerImageId} with the ID obtained at the previous step.
docker run -d --name cdn --restart=always -p 8001:8001 -p 8003:8003 -v /home/admin/ftp:/home/admin/ftp ${cdnDockerImageId}
--download-port=8001
Procedure - When Deploying with Physical Machines
Get cdn executable file
-
Download a binary package of the cdn. You can download one of the latest builds for Dragonfly on the [github releases page](https://github. com/dragonflyoss/Dragonfly2/releases).
version=1.0.0 wget https://github.com/dragonflyoss/Dragonfly2/releases/download/v$version/Dragonfly2_$version_linux_amd64.tar.gz -
Unzip the package.
# Replace `xxx` with the installation directory. tar -zxf Dragonfly2_1.0.0_linux_amd64.tar.gz -C xxx -
Move the
cdnto yourPATHenvironment variable to make sure you can directly usecdncommand.
Or you can build your own cdn executable file.
-
Obtain the source code of Dragonfly.
git clone https://github.com/dragonflyoss/Dragonfly2.git -
Enter the project directory.
cd Dragonfly2 -
Compile the source code.
make build-cdn && make install-cdn
Start cdn
cdnHomeDir=/home/admin/cdn
cdnDownloadPort=8001
cdn --home-dir=$cdnHomeDir --port=8003 --download-port=$cdnDownloadPort
Start file server
You can start a file server in any way. However, the following conditions must be met:
- It must be rooted at
${cdnHomeDir}/ftpwhich is defined in the previous step. - It must listen on the port
cdnDownloadPortwhich is defined in the previous step.
Let's take nginx as an example.
-
Add the following configuration items to the Nginx configuration file.
server { # Must be ${cdnDownloadPort} listen 8001; location / { # Must be ${cdnHomeDir}/repo root /home/admin/cdn/repo; } } -
Start Nginx.
sudo nginx
After this Task
-
After cdn is installed, run the following commands to verify if Nginx and cdn are started, and if Port
8001and8003are available.telnet 127.0.0.1 8001 telnet 127.0.0.1 8003