How to Install YOURLS on MXLinux Latest

YOURLS is a popular self-hosted URL shortening service that allows users to create their own custom short URLs for their websites. In this tutorial, we will show you how to install YOURLS on MXLinux Latest.

Prerequisites

Before we begin, you will need a few things:

Step 1: Download YOURLS

To download and install YOURLS, first, download the latest version from the official website: https://yourls.org/

wget https://github.com/YOURLS/YOURLS/archive/master.zip

Next, unzip the downloaded file:

unzip master.zip

Step 2: Create a Database

YOURLS requires a MySQL or MariaDB database to store URL records. If you haven't installed MySQL or MariaDB, you can do so by running the following command:

sudo apt-get install mysql-server

Once you have a database server running, you can create a database for YOURLS. You can do this by running the following command:

sudo mysql -u root -p -e "CREATE DATABASE yourls_db; GRANT ALL PRIVILEGES ON yourls_db.* TO 'yourls_user'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES;"

Make sure to replace yourls_db, yourls_user, and your_password with your own database name, username, and password.

Step 3: Configure YOURLS

Now that you have downloaded YOURLS and set up a database, you need to configure YOURLS. First, rename the user/config-sample.php file to user/config.php:

mv user/config-sample.php user/config.php

Next, open the user/config.php file using your favorite text editor and enter your database details:

/** MySQL database username */
define( 'YOURLS_DB_USER', 'yourls_user' );

/** MySQL database password */
define( 'YOURLS_DB_PASS', 'your_password' );

/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'yourls_db' );

/** MySQL hostname, usually localhost */
define( 'YOURLS_DB_HOST', 'localhost' );

/** MySQL tables prefix */
define( 'YOURLS_DB_PREFIX', 'yourls_' );

Step 4: Move YOURLS to your Web Server

Once you have configured YOURLS, move the entire YOURLS folder to your web server. You can do this by running the following command:

sudo mv YOURLS-master /var/www/html/yourls

Step 5: Set Permissions

Next, set the appropriate permissions for the YOURLS folder:

sudo chown -R www-data:www-data /var/www/html/yourls
sudo chmod -R 755 /var/www/html/yourls

Step 6: Set Up Virtual Host

Finally, set up a virtual host for YOURLS. You can do this by creating a new configuration file in the /etc/nginx/sites-available/ directory:

sudo nano /etc/nginx/sites-available/yourls.conf

Add the following configuration to the file:

server {
    listen 80;
    server_name yourls.example.com; #replace with your domain name
    root /var/www/html/yourls/;
    index index.php index.html;
    location / {
        try_files $uri $uri/ /yourls-loader.php$is_args$args;
    }
    location ~\.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock; #replace with your PHP version
    }
}

Save and close the file. Then, create a symbolic link for the file in the /etc/nginx/sites-enabled/ directory:

sudo ln -s /etc/nginx/sites-available/yourls.conf /etc/nginx/sites-enabled/

Finally, restart the Nginx web server for the changes to take effect:

sudo systemctl restart nginx

Step 7: Complete YOURLS Installation

Now that you have configured the web server, you can complete the YOURLS installation by accessing http://yourls.example.com/admin in your web browser. Replace yourls.example.com with your own domain name.

Follow the on-screen instructions to complete the installation. Once the installation is complete, you will be able to use YOURLS to create your own custom short URLs.

Congratulations! You have successfully installed YOURLS on MXLinux Latest!

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!