How to Install Simple-URL-Shortener on Arch Linux

In this tutorial, we will guide you through the installation process of Simple-URL-Shortener on Arch Linux. Simple-URL-Shortener is an open-source URL shortener written in PHP. It allows users to shorten URLs and also tracks the statistics of each shortened link.

Prerequisites

Before we begin, make sure that you have the following:

Step 1: Install Apache Web Server

Simple-URL-Shortener requires a web server to run. Apache is the most popular web server used on Linux systems.

To install Apache, run the following command:

sudo pacman -S apache

After the installation completes, start the Apache service using the following command:

sudo systemctl start httpd

To enable Apache to start automatically upon system startup, run:

sudo systemctl enable httpd

Step 2: Install PHP

Simple-URL-Shortener is written in PHP, so we need to install PHP and some PHP extensions to make the application work. To install PHP, run the following command:

sudo pacman -S php php-apache

After the installation completes, restart the Apache service for the changes to take effect:

sudo systemctl restart httpd

Step 3: Install MariaDB

Simple-URL-Shortener uses MariaDB or MySQL as its database. In this tutorial, we will use MariaDB.

To install MariaDB, run the following command:

sudo pacman -S mariadb

After the installation completes, start the MariaDB service using the following command:

sudo systemctl start mariadb

Run the following command to secure the MariaDB installation:

sudo mysql_secure_installation

Step 4: Create a Database and User

Now that we have installed MariaDB, let's create a database and user for Simple-URL-Shortener.

Log in to MariaDB using the root account:

sudo mysql -u root -p

Create a database for Simple-URL-Shortener:

CREATE DATABASE shorturl;

Create a user for the application and grant it all privileges on the shorturl database:

CREATE USER 'shorturl'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON shorturl.* TO 'shorturl'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace password with a strong password for the user.

Step 5: Download and Install Simple-URL-Shortener

To download Simple-URL-Shortener, we need to install Git:

sudo pacman -S git

Create a directory to host the application files:

sudo mkdir -p /srv/http/shorturl

Change to the new directory:

cd /srv/http/shorturl

Clone the Simple-URL-Shortener repository:

sudo git clone https://github.com/azlux/Simple-URL-Shortener.git .

Change the ownership of the application files to the Apache user:

sudo chown -R http:http /srv/http/shorturl

Step 6: Configure Simple-URL-Shortener

Copy the configuration file template:

sudo cp config.sample.php config.php

Edit the config.php file and set the database details:

$dbhost = "localhost";
$dbname = "shorturl";
$dbuser = "shorturl";
$dbpasswd = "password";

Replace password with the password you set in Step 4.

Step 7: Test Simple-URL-Shortener

Open a web browser and navigate to http://localhost/shorturl/. You should see the Simple-URL-Shortener homepage.

Now, let's test the URL shortening functionality. Enter a long URL in the input field and click the "Shorten URL" button. You should see a short URL that redirects to the original URL when clicked.

Conclusion

Congratulations! You have successfully installed Simple-URL-Shortener on your Arch Linux system. You can now use it to shorten your URLs and track their clicks. If you want to customize the application or customize the short URLs, refer to the official documentation.

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!