YOURLS for Self-hosted Short URLs
by walter on Dec.19, 2009, under Blogging, Linux
Visited 4035 times, 8 so far today
If you don’t want to depend on an external short URL service like bit.ly or tinyurl.com and you have access to your MySQL database, you can install and run your own with YOURLS. I managed to get it up and running in about an hour in Linux. The instructions at yourls.org mentions that an installation alongside WordPress is a bit different than the one described for a standard site. I found that to be true, and have described what I found worked after the break.
YOURLS is a free download at yourls.org. The procedure I’ll outline worked for me with the intention of using YOURLS in conjunction with WordPress. Depending on your WordPress installation, you may have to make some changes.
- Through whatever means you choose, create a new MySQL database named yourls and assign a username and password. If you don’t know how to create a database, you can find that elsewhere. If you’re using Linux, phpmyadmin is a good tool for working with MySQL databases.
- Download the zip file from yourls.org/download
- Unzip the YOURLS archive into a folder so all the internal files and folders are in a folder with a short name, like ‘y’. For instance, the path might be /var/www/y/contents of archive.
- Copy
includes/config-sample.phptoincludes/config.php - Open
includes/config.phpwith a raw text editor (like Notepad) and fill in the required settings. I’ll only list the settings that changed from their default.YOURLS_DB_USER
your MySQL username
Example: 'joe'YOURLS_DB_PASS
your MySQL password
Example: 'MySeCreTPaSsW0rd'
YOURLS_SITE
Your (short) domain URL, no trailing slash. If you’re buying a new short domain put it here, or you can use your regular domain. Also notice that this includes the folder where the YOURLS files are.
Example: 'http://yoursite.com/y'
YOURLS_HOURS_OFFSET
Timezone GMT offset
Example: '-5' -6 is correct for me, but it was offsetting wrong. Changed it to +1 and its now showing the right local time.
YOURLS_COOKIEKEY
A random secret hash used to encrypt cookies. You don’t have to remember it, make it long and complicated. Hint: generate a unique one at http://yourls.org/cookie
Example: 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm'
yourls_user_passwords
A list of username(s) and password(s) allowed to access the site if private. You'll want it to be private. I started out with it public, thinking I didn't want to mess with a login, but within the first few minutes I saw a short URL show up that I hadn't made. I don't know if that was someone else somehow doing it, or if I did it accidentally, but it was weird.
Example: 'joe' => 'mypassword'
- Upload the /y folder and all its contents to be in the same folder as WordPress' wp-contents, wp-includes, etc.
- Cross your fingers and point your browser to
http://yoursite.com/y/admin/index.php - In my case, I got a report that the database was configured correctly, but that it failed to create the .htaccess file. Instructions were given to manually create it and I placed it into the /y/ folder with the /y/ folder added into its paths.
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /y/
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^([0-9A-Za-z]+)/?$ /y/yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ /y/yourls-infos.php?id=$1 [L]
</IfModule>
# END YOURLS
- At that point, it should be ready. You can again go to
http://yoursite.com/y/admin/index.phpand you'll see a web interface to manually create short URLS.
At that point you have YOURLS installed. Now to integrate it with WordPress, you need to log into WordPress and install the YOURLS: WordPress to Twitter plugin by OZH.
Pages: 1 2
:Linux, social network, software
May 6th, 2010 on 10:57 am
Great article on how to install and setup. Example site if you don’t mind listing it:
http://igxr.com
It took me about 2 hours to setup and customize. I also setup the wordpress plugin which works nice!