YOURLS installieren

Meine Anleitung zur Installation des open-source URL-Shorteners YOURLS auf dem eigenen Webspace/Server.

Was ist YOURLS?

YOURLS ist eine open-source URL-Shortener-Applikation für den eigenen Webspace bzw. Server. Mit diesem kleinen Tool können lange Internetadressen, wie z.B. example.com/mein-artikel-hat-einen-langen-titel in example.com/a3F umgewandelt werden. Eine möglichst kurze Domain macht das Ganze natürlich noch effektiver. Ein bekannter Dienst ist z.B. „bitly“.

Systemvoraussetzungen

  • PHP 7.4
  • MySQL/MariaDB

YOURLS 1.9 setzt PHP 7.4 oder höher voraus. Ältere PHP-Versionen werden nicht mehr unterstützt. Laut der Ankündigung des Entwicklers wurde YOURLS 1.9 erfolgreich mit den PHP-Versionen 8.0 und 8.1 getestet.

Wenn du einen passenden Webspace-Anbieter suchst, dann empfehle ich dir wärmstens All-Inkl.com (Partnerlink).

Download YOURLS

Über yourls.org/download wirst du sofort auf die GitHub-Seite weitergeleitet. Dort lädst du die aktuelle Version (Latest Release) entweder als .zip oder .tar.gz herunter und entpackst die Datei.

config.php

Im Ordner user/ findest du eine Datei namens config-sample.php. Benenne diese in config.php um und öffne sie mit einem Editor deiner Wahl. Lasse dir ggf. die Zeilennummern anzeigen.

<?php
/* This is a sample config file.
 * Edit this file with your own settings and save it as "config.php"
 *
 * IMPORTANT: edit and save this file as plain ASCII text, using a text editor, for instance TextEdit on Mac OS or
 * Notepad on Windows. Make sure there is no character before the opening <?php at the beginning of this file.
 */

/*
 ** MySQL settings - You can get this info from your web host
 */

/** MySQL database username */
define( 'YOURLS_DB_USER', 'your db user name' );

/** MySQL database password */
define( 'YOURLS_DB_PASS', 'your db password' );

/** The name of the database for YOURLS
 ** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_NAME', 'yourls' );

/** MySQL hostname.
 ** If using a non standard port, specify it like 'hostname:port', e.g. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );

/** MySQL tables prefix
 ** YOURLS will create tables using this prefix (eg `yourls_url`, `yourls_options`, ...)
 ** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_PREFIX', 'yourls_' );

/*
 ** Site options
 */

/** 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' );

/** YOURLS language
 ** Change this setting to use a translation file for your language, instead of the default English.
 ** That translation file (a .mo file) must be installed in the user/language directory.
 ** See http://yourls.org/translations for more information */
define( 'YOURLS_LANG', '' );

/** Allow multiple short URLs for a same long URL
 ** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)
 ** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define( 'YOURLS_UNIQUE_URLS', true );

/** Private means the Admin area will be protected with login/pass as defined below.
 ** Set to false for public usage (eg on a restricted intranet or for test setups)
 ** Read http://yourls.org/privatepublic for more details if you're unsure */
define( 'YOURLS_PRIVATE', true );

/** 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' );

/** 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
];

/** URL shortening method: either 36 or 62
 ** 36: generates all lowercase keywords (ie: 13jkm)
 ** 62: generates mixed case keywords (ie: 13jKm or 13JKm) 
 ** For more information, see https://yourls.org/urlconvert */
define( 'YOURLS_URL_CONVERT', 36 );

/** Debug mode to output some internal information
 ** Default is false for live site. Enable when coding or before submitting a new issue */
define( 'YOURLS_DEBUG', false );

/**
* Reserved keywords (so that generated URLs won't match them)
* Define here negative, unwanted or potentially misleading keywords.
*/
$yourls_reserved_URL = [
	'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick',
];

/*
 ** Personal settings would go after here.
 */
 

Alles was editiert werden muss habe ich unten in der Liste rot markiert. Was grün ist, darüber kann optional, aber möglichst noch vor der Inbetriebnahme nachgedacht werden. Im Prinzip ist alles selbsterklärend, ich gehe aber kurz alle relevanten Zeilen (Zeilennummern hier beachten!) durch:

  • Z. 14: define( 'YOURLS_DB_USER', 'your db user name' );
    Ersetze your db user name durch den Benutzernamen der Datenbank.
  • Z. 17: define( 'YOURLS_DB_PASS', 'your db password' );
    Ersetze your db password durch das Passwort der Datenbank.
  • Z. 21: define( 'YOURLS_DB_NAME', 'yourls' );
    Ersetze yourls durch den Datenbanknamen.
  • Z. 40: define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );
    Ersetze http://your-own-domain-here.com durch die URL deiner Domain, z.B.: https://example.com
  • Z. 60: define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
    Ersetze modify this text with something random mit einem einzigartigen Wert. Du musst dich nicht daran erinnern. Ich habe einen Passwort-Generator benutzt, auf 64 Zeichen eingestellt, bestehend aus Zahlen, Groß- und Kleinbuchstaben und fertig.
  • Z. 66: 'username' => 'password',
    Ersetze usernamen und password durch deine Angaben, um dich später in YOURLS einloggen zu können. Wenn du das nächste Mal deine YOURLS-Installation aufrufst wird YOURLS das Passwort verschlüsseln. Nähere Informationen zu diesem Vorgang findest du auf der GitHub-Seite von YOURLS.
  • Z. 75: define( 'YOURLS_URL_CONVERT', 36 );
    Belasse den Wert auf 36, wenn die generierte URL aus Zahlen und Kleinbuchstaben (z.B. 13jkm) bestehen soll. Stelle den Wert auf 62, wenn die URL neben Zahlen und Kleinbuchstaben auch Großbuchstaben enthalten soll, z.B. 13jKm oder 13JKm. Letztere Einstellung hat den Vorteil, dass YOURLS mehr kurze URLs generieren kann.
  • Z. 86: Reserved Keywords (optional)
    Eventuell könnten noch Reserved Keywords von Interesse sein. Hier definierst du Keywords, die nicht in der von YOURLS generierten URL vorkommen sollen. Füge der Liste einfach weitere Keywords in vorgegebener Manier hinzu, wenn du es für nötig hältst.

Hochladen und installieren

Hast du die Datei config.php fertig bearbeitet und gespeichert, lädst du alles auf deinen Webspace/Server hoch, rufst im Browser deine Domain mit dem Anhängsel /admin/ (z.B. https://example.com/admin/) auf und klickst auf Installation. Wenn alles geklappt hat, herzlichen Glückwunsch! 👏

Kein Support!

Bitte habe Verständnis, dass ich keinen persönlichen YOURLS-Support leisten kann. Fragen oder Anregungen zu meiner Anleitung sind jedoch stets willkommen.