In this tutorial, we will be installing YOURLS, an open-source, self-hosted URL shortener, on the latest version of Elementary OS. Follow the steps below to complete the installation.
Before we begin, ensure that your Elementary OS system is up to date and has the following packages installed:
You can install these packages by running the following command in your terminal:
sudo apt-get update
sudo apt-get install apache2 php mysql-server php-mysql
Download the latest version of YOURLS from the official website by running the following command in your terminal:
wget https://yourls.org/latest.zip
Extract the downloaded zip file using the following command:
unzip latest.zip -d /var/www/html/
Change the ownership of the extracted YOURLS directory using the following command:
sudo chown -R www-data:www-data /var/www/html/yourls/
Rename the user/config-sample.php
file to user/config.php
using the following command:
mv /var/www/html/yourls/user/config-sample.php /var/www/html/yourls/user/config.php
Open the config.php
file using a text editor and add the following configuration settings:
/** MySQL database username */
define( 'YOURLS_DB_USER', 'your_mysql_username' );
/** MySQL database password */
define( 'YOURLS_DB_PASS', 'your_mysql_password' );
/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'your_database_name' );
/** MySQL hostname */
define( 'YOURLS_DB_HOST', 'localhost' );
Save and close the config.php
file.
Log in to the MySQL command-line interface using the following command:
mysql -u root -p
Enter your MySQL root password when prompted.
Create a new database for YOURLS using the following command:
create database your_database_name;
Create a new MySQL user for YOURLS using the following command:
create user 'your_mysql_username'@'localhost' identified by 'your_mysql_password';
Grant all privileges to the new MySQL user for the newly created database using the following command:
grant all privileges on your_database_name.* to 'your_mysql_username'@'localhost';
Flush the privileges using the following command:
flush privileges;
Exit the MySQL command-line interface by typing exit;
and pressing Enter.
Create a new virtual host configuration file for YOURLS using the following command:
sudo nano /etc/apache2/sites-available/yourls.conf
Paste the following configuration code into the file:
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/yourls
<Directory /var/www/html/yourls>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/yourls_error.log
CustomLog ${APACHE_LOG_DIR}/yourls_access.log combined
</VirtualHost>
Save and close the file by pressing Ctrl + X
, then Y
, and finally Enter
.
Enable the YOURLS virtual host configuration by running the following command:
sudo a2ensite yourls.conf
Reload the Apache web server using the following command:
sudo service apache2 reload
Open your web browser and navigate to http://localhost/admin/
.
Follow the on-screen instructions to configure and use YOURLS to create short URLs.
Congratulations! You have successfully installed and configured YOURLS on Elementary OS.
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!