How to Install YOURLS on OpenBSD
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.
Prerequisites
Before installing YOURLS on OpenBSD, ensure the following:
- OpenBSD is installed and running
- PHP 7.x, MySQL/MariaDB, and Apache are installed and configured
Step 1: Download and Extract YOURLS
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.zipAlternatively, 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.zipThis will create a new directory called
YOURLS-masterin your current directory.
Step 2: Configure Apache
Open the Apache configuration file
/etc/apache2/httpd.confwith your preferred text editor:$ sudo vi /etc/apache2/httpd.confAdd 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-masterdirectory and allow YOURLS to use.htaccessfiles.Save the changes and exit the text editor.
Restart Apache to apply the changes:
$ sudo apachectl restart
Step 3: Configure MySQL/MariaDB
Log in to the MySQL shell as the root user:
$ mysql -u root -pCreate 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
Step 4: Configure YOURLS
Rename the sample configuration file
user/config-sample.phptoconfig.php:$ cd YOURLS-master/user $ mv config-sample.php config.phpOpen the
config.phpfile 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
yourlsuserandyourlspasswordwith the MySQL/MariaDB user and password you created earlier, replaceyourlsdbwith the name of the MySQL/MariaDB database you created earlier, and replaceyourls.example.comwith 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.
Step 5: Test YOURLS
Open your web browser and navigate to
http://yourls.example.com/admin/.You should see the YOURLS login screen. Enter the default username
adminand the default passwordadmin, then click theLoginbutton.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 shortenfield and clicking theShortenbutton.
Congratulations, you have successfully installed YOURLS on OpenBSD!