How to install Yourls in CentOS 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


YOURLS (Your Own URL Shortener) is an open source URL shortening and data analytics application.

We will cover the process of installing YOURLS on a CentOS 8 server.


Just follow the steps below:

  • Update the system
sudo dnf install epel-release -y
sudo dnf clean all && sudo dnf update -y
  • Install httpd web server
sudo dnf install httpd -y
  • Remove the Apache welcome page
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
  • Prevent Apache from exposing files in visitors browsers
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
  • Start then enable httpd
sudo systemctl start httpd && sudo systemctl enable httpd
  • Install mariadb
sudo dnf install mariadb mariadb-server -y
  • Start and enable mariadb
sudo systemctl start mariadb.service && sudo systemctl enable mariadb.service
  • Secure the installation of MariaDB

Answer the questions you get and don’t forget to provide a root password.

  • Log into mysql shell as a root with:
mysql -u root -p
  • Create a database yourls_db, a database user yourls_user, and the database user’s password as shown below.
CREATE USER 'yourls_user'@'localhost' IDENTIFIED BY 'unixcopPassword';
GRANT ALL PRIVILEGES ON yourls_db.* TO 'yourls_user'@'localhost' IDENTIFIED BY 'unixcopPassword' WITH GRANT OPTION;
  • Install php and necessary required extensions and packages with running the commands below:
sudo dnf -y install yum-utils

sudo dnf -y install

sudo dnf -y install

dnf module reset php    #run this with root user

sudo dnf module install php:remi-7.3

sudo yum install wget git php php-bcmath php-json php-xml php-common php-curl php-intl php-zip php-imap php-pear php-cgi php-mbstring php-gd php-mysqlnd php-gettext -y
  • Install YOURLS with git.
cd /var/www/html/
sudo git clone
sudo chown -R apache:apache /var/www/html/YOURLS
  • Configure YOURLS with running the commands below
sudo cp user/config-sample.php user/config.php
sudo chown apache:apache user/config.php
  • Also modify some values in the file config.php
vim /var/www/html/YOURLS/user/config.php
  • Find the below lines in config.php file
define( 'YOURLS_DB_USER', 'your db user name' );

define( 'YOURLS_DB_PASS', 'your db password' );

define( 'YOURLS_DB_NAME', 'yourls' );

define( 'YOURLS_SITE', '' );

define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );

$yourls_user_passwords = array(
        'username' => 'password',
  • Replace them one by one as follow:
define( 'YOURLS_DB_USER', 'yourls_user' );

define( 'YOURLS_DB_PASS', 'unixcopPassword' );

define( 'YOURLS_DB_NAME', 'yourls_db' );

define( 'YOURLS_SITE', '' );

define( 'YOURLS_COOKIEKEY', 'ueejdmbsfffgsjskwnxsjssxiejdoedchcvg' ); // Use a long string consists of random characters.

$yourls_user_passwords = array(
        'unixcop' => 'unixcopPassword', // Use your own username and password.
  • Then Save and quit
  • Create a virtual host for YOURLS
vim /etc/httpd/conf.d/yourls.conf
  • Then add the following
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/YOURLS/
<Directory /var/www/html/YOURLS/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
ErrorLog /var/log/httpd/
CustomLog /var/log/httpd/ common
  • Restart httpd
sudo systemctl restart httpd
  • Allow http ports on the firewall
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
  • Go to your web browser to or http://IP_address/admin then click Install YOURLS as shown below in the screenshot.
  • Check that everything is ok and checked right or green light then press ENTER to get proceed.
  • You will be redirected to the login page as shown below .. provide your username and password you modified in the config.php file.
  • The below screenshot shows your Dashboard
  • Enjoy with YOURLS.


That’s it ..

We illustrated how to install YOURLS YOURLS (Your Own URL Shortener)in CentOS 8 Server.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"
unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook