How to Install YOURLS on Manjaro

YOURLS is a free and open-source, self-hosted URL shortening application written in PHP. In this tutorial, we will install YOURLS on Manjaro.

Prerequisites

Before we install YOURLS, we need to make sure that we have the following prerequisites installed on our Manjaro server:

Step 1: Download and Extract YOURLS

  1. Let's start by downloading YOURLS source code from the official website using the following command:
$ curl -O https://yourls.org/latest.tar.gz
  1. Once downloaded, we need to extract it using the tar command:
$ tar xvf latest.tar.gz
  1. After extraction, move the YOURLS directory to the Apache document root directory /srv/http/.
$ mv YOURLS /srv/http/
  1. Change the ownership of the YOURLS directory to the Apache user, which is usually http.
$ chown -R http:http /srv/http/YOURLS

Step 2: Create MySQL database and User

  1. Log in to your MySQL database using the following command:
$ mysql -u root -p
  1. Once logged in, create a new database for your YOURLS application using the following command:
mysql> CREATE DATABASE yourlsdb;
  1. Create a new MySQL user and assign all privileges to the yourlsdb database:
mysql> GRANT ALL PRIVILEGES ON yourlsdb.* TO 'yourlsuser'@'localhost' IDENTIFIED BY 'yourlsPassword';
  1. Lastly, exit the MySQL prompt using the following command:
mysql> exit;

Step 3: Configure YOURLS

  1. Now let's start configuring the YOURLS application. Rename user/config-sample.php to user/config.php by running the following command:
$ mv /srv/http/YOURLS/user/config-sample.php /srv/http/YOURLS/user/config.php
  1. Next, open the config.php file using your favorite editor and set the following configuration values:
// MySQL Settings
define('YOURLS_DB_USER', 'yourlsuser');
define('YOURLS_DB_PASS', 'yourlsPassword');
define('YOURLS_DB_NAME', 'yourlsdb');

// Site URL
define('YOURLS_SITE', 'http://localhost/YOURLS');

// Secret Password
define('YOURLS_ADMIN_PASSWORD', 'yourAdminSecretPassword');

Save and exit the file.

Step 4: Create Apache VirtualHost

  1. Create a new Apache VirtualHost configuration file using your favorite editor:
$ sudo nano /etc/httpd/conf/extra/yourls.conf
  1. Add the following VirtualHost configuration to the file:
<VirtualHost *:80>
    ServerName domain.com  # Replace with your domain
    ServerAlias www.domain.com  # Replace with your domain
    DocumentRoot /srv/http/YOURLS
    <Directory /srv/http/YOURLS>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

Save and exit the file.

  1. Enable the newly created VirtualHost by running the following command:
$ sudo a2ensite yourls.conf

Step 5: Restart Apache and Test YOURLS Installation

  1. Restart the Apache web server to apply the new configuration changes:
$ sudo systemctl restart httpd
  1. Open your web browser and navigate to your YOURLS installation URL. For example, http://localhost/YOURLS/.

  2. You should see the YOURLS installation page, where you can set up your new short URL service.

  3. Once you have completed the installation, you can start using YOURLS to create and manage short URLs.

Congratulations! You have successfully installed YOURLS on Manjaro.

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!