YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service. If you use YOURLS you own your data and don't need to rely on third party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses. Some of its features are listed below:
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
Terrific Plugin architecture to easily implement new features
Cool developer API
Full jsonp support
Sample files to create your own public interface and more.
To install YOURLS you don't have to own any special kind of hardware all you'll need to follow this guide is a CentOS 7 server and a domain that points to yourserverIP address and a root user. You can switch to root user from non root user using sudo -i command.
It is recommended to update your system and available packages before going through the installation process. The command below will do the job for you.
yum -y update
Installing Apache Web Server
Once the system is updated, you can install the dependencies required. To install YOURLS you will need to install the Apache web server along with MaraiDB and PHP with a few extensions.
Run the following command to install the Apache web server.
yum -y install httpd
Now you can start Apache and enable it to start at boot time, using the following commands.
You can check status of mariaDB using this below given command and you should see following output.
systemctl status mariadb.service
[root@ip-172-31-16-231 ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2017-02-14 04:05:52 UTC; 22s ago
Main PID: 10736 (mysqld_safe)
├─10736 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─10893 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/ma...
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: The latest information about MariaDB is available at http://mariadb.org/.
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: You can find additional information about the MySQL part at:
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: http://dev.mysql.com
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: Support MariaDB development by buying support/new features from MariaDB
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: Corporation Ab. You can contact us about this at firstname.lastname@example.org.
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: Alternatively consider joining our community based development effort:
Feb 14 04:05:50 ip-172-31-16-231 mariadb-prepare-db-dir: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
Feb 14 04:05:50 ip-172-31-16-231 mysqld_safe: 170214 04:05:50 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 14 04:05:50 ip-172-31-16-231 mysqld_safe: 170214 04:05:50 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 14 04:05:52 ip-172-31-16-231 systemd: Started MariaDB database server.
We recommend you make sure that this installation is secure and to do so run following command.
You'll be asked to provide root password so enter appropriate password and answer yes to all questions by pressing Y.
Enter current password for root (enter for none): Just press the Enter button
Set root password? [Y/n]: Y
New password: your-root-password
Re-enter new password: your-root-password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
Now you'll have to create a database for YOURLS so please follow the instructions.
mysql -u root -p
You'll be asked to enter password so simply enter a password and now execute the following queries to create a new database.
CREATE DATABASE yourls;
The above query will create a database named yourls. For the database you can use any name you prefer in the place of yourls. Make sure that you use semicolon at the end of each query as a query always ends with a semicolon.
Once the database is created you can create a new user and grant the required permissions to the user for the database.
CREATE USER 'yourls_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username yourls_user. You can use any preferred username instead of yourls_user. Replace StrongPassword with a strong password.
Now provide the appropriate privileges to your database user over the database you have created. Run the following query to do so.
GRANT ALL PRIVILEGES ON yourls.* TO 'yourls_user'@'localhost';
Now run the following query to immediately apply the changes on the database privileges.
Now you can exit from MariaDB prompt using following command. \q.
We will have to install PHP 7.1. To do so run following commands as shown below.
Next you'll have to restart your apache web server to load new components that we just configured and use following command to restart apache web server.
systemctl restart httpd.service
Once we have installed all the dependencies required by the YOURLS then now we can install YOURLS from github repository so we will have to first install git on our server use this command to do so.
yum -y install git
Next go to web root directory and download latest version of YOURLS from github repository as shown below.
cd /var/www/html/git clone https://github.com/YOURLS/YOURLS.git
You'll need to change proper ownership of it and you can do so with the following command.
chown -R apache:apache /var/www/html/YOURLS
You have downloaded YOURLS successfully now you'll need to configure this so configure it using below given process.
cd YOURLScp user/config-sample.php user/config.phpchown apache:apache user/config.php
You'll need to edit configuration file and you can to that using any text editor, we will use here nano text editor and you can also install it if you don't have already installed yum -y install nano
Please find these below given lines in configuration file:
define( 'YOURLS_DB_USER', 'your db user name' );
define( 'YOURLS_DB_PASS', 'your db password' );
define( 'YOURLS_DB_NAME', 'yourls' );
define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
$yourls_user_passwords = array(
'username' => 'password',
Now change these lines in accordance with:
define( 'YOURLS_DB_USER', 'yourls_user' );
define( 'YOURLS_DB_PASS', 'StrongPassword' );
define( 'YOURLS_DB_NAME', 'yourls' );
define( 'YOURLS_SITE', 'http://example.com' );
define( 'YOURLS_COOKIEKEY', 'fmoi4jfsjfasfjlkfjalfgcggjkihdgfjjgdfolsfmwemlgjhgigjgitjaaewesfsdfsdogmbnsin' ); // Use a long string consists of random characters.
$yourls_user_passwords = array(
'username1' => 'password1', // Use your own username and password.
Save the file and exit from the text editor.
Create Virtual Host
You'll need to create a virtual host to complete the installation process and you can create a virtual host file using below shown process:
Add the content below to the the file to create a virtual host. Please change server name, server admin and server alias with your domain details.
allow from all
CustomLog /var/log/httpd/yourls.example.com-access_log common
You'll need to restart the apache web server to apply changes that we just configured and we can restart our server using systemctl restart httpd.
Finally you'll have to modify firewall rules so if in case you don't have firewalld services installed on your server then you can install it using yum -y install firewalld and you can start it using systemctl start firewalld
Next run these below given commands to modify the firewalld rules.
If you find your cPanel disk space filling up, or an email address has hit its disk space quota, cPanel has a helpful built in Email Disk Usage tool. This will provide you with a simple to understand breakdown of how much disk space each folder for a particular email...
Although WHM will normally automatically keep itself up to date, you may want to manually check for server updates / push through an update that is pending, or it may be that you have automatic updates switched off on your cPanel server. In this guide we will show you how...
You may sometimes need to manually adjust the PHP settings on your cPanel server – for example if a site is hitting the PHP memory, or file size upload limit. WHM allows you to quickly change the settings of any PHP version installed on the server when needed, using the...