Preview:

Disadvantages:

Suitable for personal use only, administrators must be manually added in the configuration file, and cannot be added directly from the frontend.

Deployment Method:

Step One: Update Sources and Install Dependencies

Ubuntu/Debian:

apt update -y && apt upgrade -y
sudo apt install unzip -y  
sudo apt install git -y  

Centos:

sudo yum update -y && sudo yum upgrade -y
sudo yum install unzip -y
sudo yum install git -y

Step Two: Install Apache Web

Ubuntu/Debian:

sudo apt-get install apache2

Centos:

sudo yum install httpd -y

Step Three: Install MySQL

Ubuntu/Debian:

sudo apt-get install mysql-server

Centos:

sudo yum install mysql-server -y
sudo systemctl start mysqld

Step Four: Install PHP and Required Extensions

Ubuntu/Debian:

sudo apt-get install php php-mysql libapache2-mod-php php-cli

Centos:

sudo yum install php php-mysql php-cli
sudo systemctl restart httpd

Step Five: Configure the Database

  1. Enter MySQL

    mysql -u root -p

    Enter the root password

  2. Create Database

    CREATE DATABASE yourls;
  3. Create User and Grant Permissions

    CREATE USER 'yourls_user'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON yourls.* TO 'yourls_user'@'localhost';
  4. Restart and Exit

    FLUSH PRIVILEGES;
    EXIT;

    Step Six: Download Source Code and Unzip

    wget https://github.com/YOURLS/YOURLS/archive/refs/tags/1.9.2.zip
    unzip 1.9.2.zip

    Step Seven: Configure YOURLS

  5. Copy the Sample Configuration File:

    cp YOURLS-1.9.2/user/config-sample.php YOURLS-1.9.2/user/config.php
  6. Open the Configuration File and Make Modifications:

    nano YOURLS-1.9.2/user/config.php

    The following must be modified:

  7. Database Username:

    define( 'YOURLS_DB_USER', 'yourls_user' ); 
  8. Database Password:

    define( 'YOURLS_DB_PASS', 'password' ); 
  9. Database Name:

    define( 'YOURLS_DB_NAME', 'yourls' );
  10. COOKIEKEY (Generate at http://yourls.org/cookie):

    define( 'YOURLS_COOKIEKEY', 'modify this text with something random' ); 
  11. Admin Username and Password (If unmodified, username will be "username" and password will be "password," multiple users can be added for management here):

    $yourls_user_passwords = [
     'username' => 'password',
     // 'username2' => 'password2',
     // You can have one or more 'login'=>'password' lines
    ];
  12. Access URL (Remember to resolve this URL to host IP):

    define( 'YOURLS_SITE', 'http://example.com' );

    The following can be modified optionally:

  13. Allow Public Use (true for not allowed, false for allowed):

    define( 'YOURLS_PRIVATE', true );
  14. Allow Multiple Short Links to Point to the Same Long Link (For example, after enabling, both a.com/1 and a.com/2 will redirect to b.com, useful for analyzing data for each short link during multi-platform promotion):

    define( 'YOURLS_UNIQUE_URLS', true );
  15. Change Language (Default is English, for Chinese version enter 'zh_CN', further configuration is required later):

    define( 'YOURLS_LANG', '' );
  16. Exclude Sensitive Words (Long URLs containing the specified sensitive words will not be shortened):

    $yourls_reserved_URL = [
     '1',
    ];

    Step Eight: Install Language Pack (Skip if Language is Not Changed)

    git clone https://github.com/ZvonimirSun/YOURLS-zh_CN.git && mv YOURLS-zh_CN/* /root/YOURLS-1.9.2/user/languages/ && rm -rf YOURLS-zh_CN

Step Nine: Configure and Restart Apache

sudo mv /root/YOURLS-1.9.2/* /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
sudo systemctl restart apache2

Conclusion:

Feel free to leave your shortened links in the comment section and see how short they can get.

Tag:Configure, YOURLS, URL Shortening Platform

Original link:http://enblog.fuyiran.link/Technology/16.html

Copyright: All posts on this blog, unless otherwise stated, are published using theCC BY-NC-SA 4.0 license agreement. Please indicate the source for reprinting Fu Speaking (enblog.fuyiran.link)

Add a new comment.