YOURLS stands for Your Own URL Shortener. YOURLS is a set of PHP scripts that allow you to run your URL shortening service (a la TinyURL or bitly).
This tutorial will explain how to install YOURLS on OpenBSD.
Before installing YOURLS on OpenBSD, ensure the following:
Download the latest version of YOURLS from the official website by running the following command in your OpenBSD terminal:
$ ftp https://github.com/YOURLS/YOURLS/archive/master.zip
Alternatively, you can download the latest stable release by visiting the YOURLS release page and downloading the .zip file directly.
Extract the downloaded file by running the following command:
$ unzip master.zip
This will create a new directory called YOURLS-master
in your current directory.
Open the Apache configuration file /etc/apache2/httpd.conf
with your preferred text editor:
$ sudo vi /etc/apache2/httpd.conf
Add the following lines at the end of the <VirtualHost *:80>
block:
DocumentRoot "/var/www/YOURLS-master"
ServerName yourls.example.com
<Directory "/var/www/YOURLS-master">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
This will configure Apache to serve YOURLS from the YOURLS-master
directory and allow YOURLS to use .htaccess
files.
Save the changes and exit the text editor.
Restart Apache to apply the changes:
$ sudo apachectl restart
Log in to the MySQL shell as the root user:
$ mysql -u root -p
Create a new database for YOURLS:
mysql> CREATE DATABASE yourlsdb;
Create a new MySQL user for YOURLS and grant it full privileges on the database:
mysql> CREATE USER 'yourlsuser'@'localhost' IDENTIFIED BY 'yourlspassword';
mysql> GRANT ALL PRIVILEGES ON yourlsdb.* TO 'yourlsuser'@'localhost';
mysql> FLUSH PRIVILEGES;
Exit the MySQL shell:
mysql> quit
Rename the sample configuration file user/config-sample.php
to config.php
:
$ cd YOURLS-master/user
$ mv config-sample.php config.php
Open the config.php
file with your preferred text editor and modify the following lines:
/** Database connection settings */
define( 'YOURLS_DB_USER', 'yourlsuser' );
define( 'YOURLS_DB_PASS', 'yourlspassword' );
define( 'YOURLS_DB_NAME', 'yourlsdb' );
define( 'YOURLS_DB_HOST', 'localhost' );
/** Site URL */
define( 'YOURLS_SITE', 'http://yourls.example.com' );
/** Signature salt */
define( 'YOURLS_SECRET', 'yourlssecret' );
Replace yourlsuser
and yourlspassword
with the MySQL/MariaDB user and password you created earlier, replace yourlsdb
with the name of the MySQL/MariaDB database you created earlier, and replace yourls.example.com
with the domain name or IP address of your server.
You can generate a unique secret for YOURLS using a tool like Random.org.
Save the changes and exit the text editor.
Open your web browser and navigate to http://yourls.example.com/admin/
.
You should see the YOURLS login screen. Enter the default username admin
and the default password admin
, then click the Login
button.
You should now see the YOURLS administration interface. You can begin generating short URLs by entering a long URL in the Enter a new URL to shorten
field and clicking the Shorten
button.
Congratulations, you have successfully installed YOURLS on OpenBSD!
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!