How to install YOURLS on Centos 7

/ Category: Tutorials / Comments: 1

How to install YOURLS on Centos 7
Spread the love

We’ll show you, How to install YOURLS on Centos 7. Your Own URL Shortener or simply YOURLS is very useful set of PHP scripts that will allow you to run your self-hosted URL shortening service. In this tutorial we will install and configure YOURLS on a CentOS 7 VPS with Apache web server, MariaDB and PHP, which is pretty fast and straightforward.

YOURLS has a lot of useful features:

  • Free and Open Source software.
  • Private (your links only) or Public (everybody can create short links, fine for an intranet)
  • Sequential or custom URL keyword
  • Handy bookmarklets to easily shorten and share links
  • Awesome stats: historical click reports, referrers tracking, visitors geo-location
  • Neat Ajaxed interface
  • Terrific Plugin architecture to easily implement new features
  • Cool developer API
  • Full jsonp support
  • Friendly installer
  • Sample files to create your own public interface
    and many more

1. Update your server

Login to your CentOS 7 VPS via SSH as user root

ssh [email protected]_Address -p Port_number

and make sure that all installed packages are up to date

yum update

2. Install Apache web server

yum install httpd

Once installed, start the web server and enable it to start at system boot

systemctl start httpd.service
systemctl enable httpd.service

3. Install MySQL/MariaDB

Run the following command to install MariaDB on your server

yum install MariaDB-server

Start MariaDB service and enable it to start at boot

systemctl start mariadb.service
systemctl enable mariadb.service

Once the database server is installed, execute the ‘mysql_secure_installation’ post-installation script to set your MySQL root password and secure the server.


Now, create a new user and database for YOURLS

MariaDB [(none)]> CREATE DATABASE yourlsdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON yourls.* TO 'yourlsuser'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';
MariaDB [(none)]> \q

4. Install and configure YOURLS

We have to download YOURLS from their official GitHub repository, so make sure that git is installed on your server

yum install git

Get YOURLS from GitHub

cd /var/www/html/
git clone

Change the ownership of YOURLS files

chown -R apache:apache YOURLS/

Copy the sample YOURLS configuration file

cp user/config-sample.php user/config.php

Open the configuration file and update the following lines

nano user/config.php

define( 'YOURLS_DB_USER', 'yourlsuser' );
define( 'YOURLS_DB_NAME', 'yourlsdb' );
define( 'YOURLS_DB_HOST', 'localhost' );
define( 'YOURLS_SITE', '' );
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
$yourls_user_passwords = array(
        'user' => 'password', // Use your actual username and password.

5. Create Apache virtual host

Create a virtual host directive, so you can access YOURLS with your domain name.

nano /etc/httpd/conf.d/yourls.conf

	ServerAdmin [email protected]
	DocumentRoot /var/www/html/YOURLS/
	Options FollowSymLinks
	AllowOverride All
	Order allow,deny
	allow from all
	ErrorLog /var/log/httpd/
	CustomLog /var/log/httpd/ common

Save the file and restart Apache for the changes to take effect.

Now, go to and follow the on-screen instructions to complete the YOURLS installation.

Of course you don’t have to install YOURLS on Centos 7 if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install YOURLS on Centos 7 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.


  Comments: 1

  1. Yeah, this does not seem to be quite correct.

    httpd[3108]: AH00526: Syntax error on line 4 of /etc/httpd/conf.d/yourls.conf:
    ServerAlias only used in

Your feedback