How to Install Schort on NetBSD

Schort is an open-source URL shortening service written in PHP. In this tutorial, we will go through the steps to install Schort on NetBSD.

Prerequisites

Before installing Schort, make sure to have the following prerequisites installed on your system:

Step 1: Clone Schort repository

First, clone the Schort repository from GitHub using the following command in the terminal:

git clone https://github.com/sqozz/schort.git

This will download the Schort source code to your system.

Step 2: Configure MariaDB/MySQL database

Create a new database for Schort to use, and a user to access the database with the following SQL commands:

CREATE DATABASE schort;
CREATE USER 'schort_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON schort.* TO 'schort_user'@'localhost';

Replace "password" with your preferred password for the user.

Step 3: Configure Schort

Copy the sample configuration file config.example.php to config.php:

cd schort
cp config.example.php config.php

Edit the config.php file and set the database information to match the database you created earlier:

$config['database'] = [
    'dsn' => 'mysql:host=localhost;dbname=schort',
    'username' => 'schort_user',
    'password' => 'password',
];

You can also configure other settings in this file, such as the site name and URL prefix.

Step 4: Set file permissions

Set the file permissions for Schort to run properly by issuing the following commands:

chmod -R 755 uploads
chmod -R 755 cache
chmod -R 755 logs

Step 5: Create the shortened URL endpoint

Create an Apache .htaccess file in the root directory of the Schort installation with the following content:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?r=$1 [QSA,L]

This file ensures that all requests are routed through Schort's index.php script, which handles short URL redirections.

Step 6: Test Schort

Start the Apache web server by running the following command:

apachectl start

Then, open a web browser and navigate to http://localhost/schort. If everything is set up correctly, you should see the Schort homepage with a form to enter a URL to shorten.

Conclusion

Congratulations! You have successfully installed Schort on NetBSD. You can now start using it to shorten URLs and share them with others.

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!