How-To: Make Your Own URL Shortener

YOURLS Install Guide

Step 1 – Download and copy install files
Download from: https://github.com/YOURLS/YOURLS/releases
Extract Zip archive
Copy all install files to the root of your hosting using FTP (usually www, wwwroot, or htdocs)

Step 2 – Create your database and user (using phpMyAdmin)
Login to your phpMyadmin control panel, click over to the Users tab and click Add user
Create a username, set host to localhost, and create a password for your account.
Check the box to Create database with the same name and grant all privileges to also create a database for this user at the same time.
Click Go to create the account.

Step 3 – Edit the config file
Go to the user folder and rename the file config-sample.php to config.php. Open the file with a text editor.
This file will define all the settings for your Yourls install.
Database settings

  • Define the user and password you created earlier in the following lines:
    define( 'YOURLS_DB_USER', ‘your db user name’ );
    define( 'YOURLS_DB_PASS', ‘your db password’ );
  • If you made your database name anything other than yourls, edit the database name here:
    define( 'YOURLS_DB_NAME', 'yourls' );

Site options

  • Define your site domain (be sure not to leave a trailing “/“):
     define( 'YOURLS_SITE', 'http://site.com' );
  • Define your time zone:
     define( 'YOURLS_HOURS_OFFSET', 0 );
  • Generate a cookie key by typing random gibberish into this line:
     define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
  • Set you user account(s) (delete the username2 if you only want one user, add multiple users by ending each line with a comma):
    Note: The password is stored in plaintext now, but will be hashed the first time YOURLS is run, so the password will be safe.

    $yourls_user_passwords = array(
    'username' => 'password',
    'username2' => 'password2' // You can have one or more 'login'=>'password' lines
    );
  • (Optional) Set your URL conversion settings:
    define( 'YOURLS_URL_CONVERT', 36 ); will create lowercase keywords.
    define( 'YOURLS_URL_CONVERT', 62 ); will create mixed case keywords.
  • (Optional) Exclude words from URL generation:
    $yourls_reserved_URL = array(
    ‘word1’, ‘word2’,
    );

Save the config.php file.

Step 4 – Install YOURLS
Navigate to http://yourdomain.com/admin to run the installer.
Click Install.
The install will generate a few errors about not creating tables, but if you go back to your phpMyAdmin control panel, you can see that the tables were created.
Navigate back to http://yourdomain.com/admin. You will be presented with a login page. Enter the account you defined in the config.php file.
YOURLS is now installed.

That’s it, all-in all it shouldn’t take more than 10 minutes to get up and running. You can create bookmarklets to make shorting easier by going to the Tools page.

You can find out more info about YOURLS at yourls.org.

This clip appeared in episode 25 of Techspresso.

Catch up with up on Facebook: facebook.com/techspresso
Follow us on Twitter: @Techspresso

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>