How to Install Simple-URL-Shortener on Ubuntu Server Latest

In this tutorial, we will guide you on how to install Simple-URL-Shortener on Ubuntu Server Latest. Simple-URL-Shortener is an open-source URL shortening tool written in PHP, and it allows users to shorten long URLs into short, easy-to-remember links. We will install Simple-URL-Shortener from its GitHub repository using the command line interface.

Prerequisites

Before we start, make sure that you have the following prerequisites:

Step 1 - Installing Apache Web Server

If you haven't installed the Apache web server yet, you can install it by running the following command:

sudo apt install apache2

After the installation is complete, you can verify that Apache is running by accessing your server's IP address on a web browser. If Apache is running, you should see the default Apache welcome page.

Step 2 - Installing MySQL/MariaDB Database Server

Simple-URL-Shortener requires a database server to store its data. We will install and configure the MySQL/MariaDB database server on our Ubuntu server.

sudo apt install mariadb-server

After the installation is complete, you can secure the database installation by running the following command:

sudo mysql_secure_installation

Follow the on-screen prompts and enter a strong root password and remove unwanted default settings.

Step 3 - Installing Git

Simple-URL-Shortener is available on GitHub, and we will use Git to download the repository.

sudo apt install git

Step 4 - Cloning Simple-URL-Shortener Repository

We will download the Simple-URL-Shortener repository from GitHub using Git with the following command:

sudo git clone https://github.com/azlux/Simple-URL-Shortener.git /var/www/html/shortener

After the cloning is complete, change the ownership of the shortener directory to the Apache user with the following command:

sudo chown -R www-data:www-data /var/www/html/shortener

Step 5 - Creating a New MySQL/MariaDB Database and User

We will create a new MySQL/MariaDB database and user for the Simple-URL-Shortener installation.

Log in to the MySQL shell by running the following command and enter the root password when prompted:

sudo mysql -u root -p

Create a new database with the following command:

CREATE DATABASE shortenerdb;

Create a new MySQL/MariaDB user with the following command:

CREATE USER 'shorteneruser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password123';

Grant full access to the shortener database for the shorteneruser with the following command:

GRANT ALL PRIVILEGES ON shortenerdb.* TO 'shorteneruser'@'localhost';

Exit the MySQL shell by running the following command:

exit;

Remember to replace password123 with a strong password for your user.

Step 6 - Configuring Simple-URL-Shortener

Navigate to the Simple-URL-Shortener installation directory with the following command:

cd /var/www/html/shortener

Copy the config.php.sample file to config.php with the following command:

sudo cp config.php.sample config.php

Edit the config.php file with your favorite text editor:

sudo nano config.php

Update the database credentials with the MySQL/MariaDB database and user we created earlier. Replace <DATABASE> with the name of the database you created, <USER> with the name of the database user you created, and <PASSWORD> with the database user's password:

define("DATABASE_NAME", "<DATABASE>");
define("DATABASE_USER", "<USER>");
define("DATABASE_PASSWORD", "<PASSWORD>");
define("DATABASE_HOST", "localhost");

Save and exit the file.

Step 7 - Accessing Simple-URL-Shortener

Navigate to your Ubuntu server's IP address with a web browser, followed by /shortener:

http://server-ip/shortener

You should see the Simple-URL-Shortener installation page. Follow the on-screen prompts to complete the installation.

Conclusion

In this tutorial, we have shown you how to install Simple-URL-Shortener on Ubuntu Server Latest. You can now start using Simple-URL-Shortener to shorten long URLs into easy-to-remember links.

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!