URL Shortener is an application used to make a link a site becomes shorter. The purpose of the application is to save characters and also more neatly in a post. Examples of URL shortener applications that are often used are goo.gl, bitly.com or tr.im.
Instead, we write the link http://www.ngoprek.biz/how-to-force-user-to-change-its-password-in-linux/ so it’s better to use URL shortener so the link above can be minimized to be https://goo.gl/f1NSv1. But the disadvantage of using a URL shortener belongs to a third party is that we cannot fully manage the application so we may find it difficult if we want to see how many people who clicked on our URL or maybe we want to create an application based on the link or something like that.
Therefore, a developer named Ozh makes YOURLS or Your Own URL Shortener, a URL shortener application that we can install on our server so we have a personal URL shortener application. The benefits of using the application are free, open source, easy to install, have statistical features, fox-changing URLs, and plugins available for this app. This tutorial will explain how to install YOURLS on Centos 7.
Before we install, please disable SELinux and Firewall first on your server. After that install the packages:
Turn on mariadb and then create a database for YOURLS on mariadb:
Then we download the package YOURLS which until this article is made up to version 1.7.2 and then extract it.
Please note there are two options when we want to use YOURLS in our server that is using yourls application in document root or in subdirectory. Using YOURLS application in document root means all yourls files are in /var/www/html folder whereas in subdirectory it means all yourls files are in certain subdirectory in /var/www/html. This article use yourls application in the document root. After that we copy all files and folders of YOURLS to /var/www/html:
Then we copy config file:
and we configure config.php in user folder like this:
For the last variable (YOURLS_SITE) because I don’t have a domain so I use the IP server. If we use a domain, then we can change it into the domain name. After configuring yourls, we will now configure apache for the htaccess feature of the file to be turned on. Change AllowOverride section on DocumentRoot “/var/www/html” should be changed its value to All and add index.php to DirectoryIndex as below:
After that restart httpd:
Then we create file .htaccess in /var/www/html and insert the script:
After that we open browser and type:
and will display like this:
Click Install Yourls and will be displayed:
Ignore the error because we have already created .htaccess file and then click YOURLS Administration Page there will be display:
Default, username, and password for yourls is username and password. Click Login, there will be display:
You can add new username and password for YOURLS in config.php on yourls_user_passwords section. The example we want to add username ngoprek and its password is qwerty, so add in the section like this:
After that, log out from YOURLSand try your new username. Now we want to try to add URL shortener for http://www.ngoprek.biz/how-to-force-user-to-change-its-password-in-linux/ page. Insert the link in the Enter the URL column and then click Shorten The URL:
And here is the result:
Now open in browser and type:
and the browser will open the page:
If we want to see the statistic of the page you can click stats in Actions column:
And here is the statistic result:
Default, we can see there is error display on YOURLS page like this:
Could not auto-encrypt passwords. Error was: “cannot write file”. Get help.
Click here to dismiss this message for one week.
You can solve the error with command:
and then log out from YOURLS and login again and it should error display will disappear:
If you do not want to install YOURLS in DocumentRoot or in /var/www/html but want to install in subdirectory example subdirectory yourls in folder /var/www/html, you must change .htaccess to be like this:
After that restart webserver.
You can install YOURLS using yum with commands:
But you must remember that the location of YOURLS files in /usr/share/yourls/ and you can follow the commands above to complete installation YOURLS using yum.