How to install shorturl on Ubuntu Server Latest

In this tutorial, you will learn how to install shorturl on an Ubuntu Server Latest system. Shorturl is a URL shortener web application, which allows you to create short aliases for long URLs, making them easier to share and remember. The system is written in Python and is distributed under the MIT License.

Prerequisites

Step 1: Install Python3 and pip3

Python3 and pip3 should already be installed on your Ubuntu server, but if it is not, you can use the following command to install them:

sudo apt-get update
sudo apt-get install python3-pip -y
sudo apt-get install python3 -y

Step 2: Install shorturl

To install shorturl, you must clone the project repository from Github. First, navigate to the directory where you want to install the application:

cd /path/to/installation/

Next, clone the repository:

git clone https://git.mills.io/prologic/shorturl.git

Change to the shorturl directory:

cd shorturl/

Install the Python requirements from the requirements.txt file using the following command:

pip3 install -r requirements.txt

Step 3: Configure shorturl

The configuration file for shorturl is located in the config.py file. Copy the sample configuration file and edit the values to match your needs:

cp config.py.example config.py
nano config.py

Update the following variables:

SECRET_KEY = 'your_secret_key'
DATABASE_URI = 'postgresql://user:password@localhost/shorturl'

Step 4: Setup the database

You will need to create a PostgreSQL database for shorturl. Login to the PostgreSQL database using your username and password:

sudo su postgres
psql

Create a new database named shorturl_db:

CREATE DATABASE shorturl_db;

Next, create a new user named shorturl with a password:

CREATE USER shorturl WITH PASSWORD 'password';

Grant all privileges to the shorturl user with the following command:

GRANT ALL PRIVILEGES ON DATABASE shorturl_db TO shorturl;

Exit from psql and return to your regular user account:

\q
exit

Next, initialize the database schema by running the following command:

python3 manage.py db init
python3 manage.py db migrate
python3 manage.py db upgrade

Step 5: Starting the application

To start the application, use the following command:

python3 run.py

The application will listen on port 5000 by default. You can access it by navigating to http://YOUR_SERVER_IP:5000 in your web browser.

Conclusion

In this tutorial, you learned how to install and configure shorturl on an Ubuntu Server Latest system. You also learned how to set up a PostgreSQL database, initialize the database schema, and start the application. You should now be able to use this URL shortener to create short aliases for long URLs.

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!