How to Install Simple-URL-Shortener on FreeBSD Latest

Simple-URL-Shortener is an open source URL shortener which allows users to create short and customizable URLs. In this tutorial, we will guide you on how to install Simple-URL-Shortener on FreeBSD latest.

Prerequisites

Before we begin, you need to ensure you have the following:

Step 1: Install Dependencies

To get started, we need to install some dependencies. Run the following command to install the dependencies:

pkg install php74 php74-openssl php74-pdo php74-pdo_mysql php74-filter php74-json php74-ctype php74-iconv php74-session php74-simplexml php74-hash php74-curl php74-tokenizer

This command installs PHP and the required PHP extensions that Simple-URL-Shortener needs to run smoothly.

Step 2: Install MariaDB Database

We need to install MariaDB, which is a popular database that Simple-URL-Shortener can use. Run the following command to install MariaDB:

pkg install mariadb104-server

After installing MariaDB, we need to configure it. Run the following command to create the MariaDB database:

/usr/local/bin/mysql_install_db --user=mysql

Now, start the database service by running the following command:

service mysql-server start

To secure MariaDB installation, run the following command:

mysql_secure_installation

This command prompts you to set a root password and apply other security settings.

Step 3: Install Apache Web Server

Simple-URL-Shortener also requires a web server to serve content to the user. We need to install Apache web server to do this. Run the following command to install Apache:

pkg install apache24

After installation, start the Apache server by running the following command:

service apache24 start

Step 4: Download and Install Simple-URL-Shortener

Now, we need to download Simple-URL-Shortener source code from Github. Run the following command to download the source code:

cd /usr/local/www
git clone https://github.com/azlux/Simple-URL-Shortener.git shorten

After downloading, change the ownership of the files to Apache by running the following command:

chown -R www:www /usr/local/www/shorten

Step 5: Create Virtual Host Configuration

We need to create a virtual host to instruct Apache to serve Simple-URL-Shortener. Run the following command to open a new configuration file:

nano /usr/local/etc/apache24/includes/shorten.conf

Paste the following configuration into the file:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /usr/local/www/shorten/public
    ServerName shorten.example.com

    <Directory /usr/local/www/shorten/public>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd-shorten-error.log
    CustomLog /var/log/httpd-shorten-access.log combined
</VirtualHost>

Save and exit the configuration file.

Step 6: Restart Apache and MariaDB

Now that installation and configuration are done, we need to restart Apache and MariaDB for changes to take effect. Run the following commands:

service apache24 restart
service mysql-server restart

Step 7: Configure Simple-URL-Shortener

Open the Simple-URL-Shortener configuration file by running the following command:

nano /usr/local/www/shorten/.env

In this file, update the database informations and configure other settings according to your preferences.

Step 8: Access Simple-URL-Shortener

Open a web browser and navigate to the URL, http://shorten.example.com/, where shorten.example.com is the hostname you have configured previously.

You should now see the Simple-URL-Shortener dashboard where you can create short URLs.

Conclusion

In this tutorial, we have installed Simple-URL-Shortener on FreeBSD latest. You may now use this tool to shorten your URLs and share it 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!