YOURLS (Your Own URL Shortener) is a free and open-source software that allows you to create and manage your own URL shortener. In this tutorial, we will guide you through the steps of installing YOURLS on Ubuntu Server Latest.
Before proceeding with the installation, make sure that you have the following requirements:
First, update the package repository cache of your system.
sudo apt update
Install PHP and required extensions using the following command.
sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml
Download the latest stable version of YOURLS from the official website.
cd /var/www/html
sudo wget https://github.com/YOURLS/YOURLS/releases/latest/download/yourls-latest.zip
Unzip the downloaded file using the following command.
sudo unzip yourls-latest.zip
Rename the extracted directory to something more meaningful.
sudo mv YOURLS-*/ yourls
Set the correct ownership and permissions to the YOURLS directory.
sudo chown -R www-data:www-data /var/www/html/yourls/
sudo chmod -R 755 /var/www/html/yourls/
Create a new database and user for YOURLS to use. This can be done using PHPMyAdmin or the MySQL command-line interface.
mysql -u root -p
mysql> CREATE USER 'yourlsuser'@'localhost' IDENTIFIED BY 'yourlspassword';
mysql> CREATE DATABASE yourls_db;
mysql> GRANT ALL PRIVILEGES ON yourls_db.* TO 'yourlsuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Copy the configuration file user/config-sample.php
to user/config.php
.
cd /var/www/html/yourls/user
sudo cp config-sample.php config.php
Open the config.php
file using a text editor and update the following lines.
define( 'YOURLS_DB_USER', 'yourlsuser' );
define( 'YOURLS_DB_PASS', 'yourlspassword' );
define( 'YOURLS_DB_NAME', 'yourls_db' );
define( 'YOURLS_SITE', 'http://yourdomain.com' );
Save and close the file.
Create a new virtual host for YOURLS.
sudo nano /etc/apache2/sites-available/yourls.conf
Add the following configuration to the file and save it.
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/yourls
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<Directory "/var/www/html/yourls">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/yourls_error.log
CustomLog ${APACHE_LOG_DIR}/yourls_access.log combined
</VirtualHost>
Enable the virtual host and restart the Apache service.
sudo a2ensite yourls.conf
sudo systemctl restart apache2
Open your web browser and type the URL http://yourdomain.com
in the address bar. You should see the YOURLS installation page.
Follow the on-screen instructions to complete the installation process.
Congratulations! You have successfully installed YOURLS on Ubuntu Server Latest. You can now create and manage your own URL shortener.
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!