Root-Server Tutorial

ROOT-SERVER TUTORIAL

Install YOURLS on Debian

Learn how to install YOURLS on Debian servers

Author:

Zoey Löchner

Last updated:

16/01/2021

Introduction

In this tutorial you will learn how to install YOURLS.

I am doing this on a Debian 11 server (RS Zimtstern) but the installation procedure should also work on other Debian versions.

Requirements

You need Apache2, PHP and MariaDB installed on your server, see here.

Installing YOURLS

YOURLS is an open source URL shortener with a web GUI.

  • Follow Step 1.5 and create a new domain or subdomain for the website.
  • Switch to the folder you have just created (replace FOLDER with the name of the folder) by executing the following commands:
cd /var/www/
git clone https://github.com/YOURLS/YOURLS.git
mv YOURLS FOLDER
cd FOLDER

Now we have to configure YOURLS:

cd user
cp config-sample.php config.php
nano config.php

You need to make the following changes:

  • Replace 'your db user name' with your database username.
/** MySQL database username */
define( 'YOURLS_DB_USER', 'your db user name' );
  • Replace 'your db password' with your database password.
/** MySQL database password */
define( 'YOURLS_DB_PASS', 'your db password' );
  • Replace 'yourls' with your database name (username).
/** The name of the database for YOURLS
 ** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_NAME', 'yourls' );
  • Replace 'http://your-own-domain-here.com' with your URL.
/** YOURLS installation URL
 ** All lowercase, no trailing slash at the end.
 ** If you define it to "http://sho.rt", don't use "http://www.sho.rt" in your browser (and vice-versa)
 ** To use an IDN domain (eg http://héhé.com), write its ascii form here (eg http://xn--hh-bjab.com) */
define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );
  • Replace modify this text with something random with random letters and numbers.
/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated
 ** Hint: copy from http://yourls.org/cookie */
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
  • Now you need to create a user and define a (secure) password. Replace 'username' => 'password', .
/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
 ** YOURLS will auto encrypt plain text passwords in this file
 ** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords = [
    'username' => 'password',
    // 'username2' => 'password2',
    // You can have one or more 'login'=>'password' lines
];
  • Save your changes by pressing CTRL + X, then y and finally by hitting ENTER.
  • Open YOURLS by accessing https://DOMAIN/admin and follow the steps shown to log in.

Step 1.1 - Remove unneeded sample files

Remove sample files no longer needed by executing:

cd /var/www/FOLDER
rm sample*
cd user/plugins
rm -r sample*

Step 1.2 - Update YOURLS

  • Switch to the YOURLS folder.
  • Replace "FOLDER" in the next command with the YOURLS folder and execute the following commands:
cd /var/www/FOLDER
git fetch origin
git reset --hard origin/master

Step 1.3 - Installing a modern YOURLS theme (sleeky)(optional)

  • Switch to the YOURLS folder.
  • Replace "FOLDER" in the next command with the folder of YOURLS and run:
cd /var/www/FOLDER/user/plugins
git clone https://github.com/Flynntes/Sleeky.git
mv Sleeky/sleeky-backend/ ./
rm -r Sleeky
Step 1.3.1 - Update sleeky
  • Switch to the YOURLS folder.
  • Replace "FOLDER" in the next command with the folder of YOURLS and run:
cd /var/www/FOLDER/user/plugins
rm -r sleeky-backend
git clone https://github.com/Flynntes/Sleeky.git
mv Sleeky/sleeky-backend/ ./
rm -r Sleeky

Conclusion

You have now installed a YOURLS URL shortener.
This tutorial contains content of https://github.com/SanCraftDev/Debian-Setup/blob/main/README.md and https://github.com/louislam/uptime-kuma.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributor's Certificate of Origin

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or

  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or

  3. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.

Published 16/01/2021 by Zoey Löchner

Submit your tutorial

Get 60€ netcup vouchers for every published tutorial.