banner
oldcatY

oldcatY

中轻度LoveLive厨,主推莲团,二推水+虹团(缪团是神,星团……)
twitter
github
bilibili
steam

[Software Recommendation] Self-hosted URL shortening service - YOURLS

*** (Reprinted from gao.ee)***, this tutorial uses Docker to build, and the system uses Debian 10.

1. Build Docker Environment#

Build Environment Overseas#

curl -sSL https://get.docker.com/ | sh

Build Environment in China#

curl -sSL https://get.daocloud.io/docker | sh

2. Build YOURLS using Docker-Compose#

2.1. Create docker-compose.yml#

mkdir -p /root/data/docker_data/yourls

cd /root/data/docker_data/yourls

nano docker-compose.yml

2.2 Modify docker-compose.yml#

version: "3.5"
services:

  mysql:
    image: mysql:5.7.22              # If you encounter incorrect database configuration or cannot connect to the database,PDOException: SQLSTATE[HY000] [1045] Access denied for user 'yourls'@'yourls_service.yourls_default' (using password: YES), you can change 5.7.22 to 5.7
    environment:
      - MYSQL_ROOT_PASSWORD=my-secret-pw
      - MYSQL_DATABASE=yourls
      - MYSQL_USER=yourls
      - MYSQL_PASSWORD=yourls
    volumes:
      - ./mysql/db/:/var/lib/mysql
      - ./mysql/conf/:/etc/mysql/conf.d
    restart: always
    container_name: mysql
  
  yourls:
    image: yourls
    restart: always
    ports:
      - "8200:80"
    environment:
      YOURLS_DB_HOST: mysql
      YOURLS_DB_USER: yourls
      YOURLS_DB_PASS: yourls
      YOURLS_DB_NAME: yourls
      YOURLS_USER: admin      # Choose your own name
      YOURLS_PASS: admin      # Choose your own login password
      YOURLS_SITE: https://gao.ee  # Change to your own domain name
      YOURLS_HOURS_OFFSET: 8
    volumes:
      - ./yourls_data/:/var/www/html   
    container_name: yourls_service
    links:
      - mysql:mysql

After writing, press Ctrl + X, then press y to save and exit.

2.3 Check Port Occupancy#

apt install lsof
lsof -i:8200

If there is any occupation, use kill -9 programPID to close the corresponding program.

2.4 UPUP#

docker-compose up -d 

3. Reverse Proxy#

This tutorial uses mdserver-web for reverse proxy, Baota/AAPANEL is the same

Image
After reverse proxy, enter http://domain/admin to start the installation.

4. Program Update#

cd /root/data/docker_data/yourls  # Enter the folder where docker-compose is located
docker-compose pull    # Pull the latest image
docker-compose up -d   # Re-update the current image

5. Program Uninstall#

5.1 Uninstall YOURLS Service#

sudo -i  # Switch to root
cd /root/data/docker_data/yourls  # Enter the folder where docker-compose is located
docker-compose down    # Stop the container, the data mapped to the local will not be deleted at this time
cd ~
rm -rf /root/data/docker_data/yourls  # Completely delete the data mapped to the local

5.2 Uninstall Docker#

sudo apt-get remove docker docker-engine
rm -fr /var/lib/docker/
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.