How to Install Polr on CentOS 8

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

Introduction

Polr is a quick, modern, and open-source link shortener. It allows you to host your own URL shortener, to brand your URLs, and to gain control over your data. It’s also GPLv2+ licensed.

Polr is a free and open-source link shortener written in PHP and Lumen. It allows you to quickly host your own URL shortener.

Install Apache Service

Polr requires:

  • Web server
  • MySQL database
  • PHP

Install the Apache web server.

dnf install httpd -y

Enable apache service

systemctl enable httpd.service

Open ports 80 (HTTP) and 443 (HTTPS) for hhtpd service

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Make a new configuration file for the Polr installation.

vim /etc/httpd/conf.d/polr.conf

And then add the following

<VirtualHost *:80>
    ServerName polr.unixcop.com
    ServerAlias polr.unixcop.com
    DocumentRoot "/var/www/html/public"
    <Directory "/var/www/html/public">
        Require all granted
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined
</VirtualHost>

You can replace polr.unixcop.com with your own domain.

Install PHP

Polr requires PHP and PHP modules.

dnf install -y php php-mysqlnd php-mbstring  php-curl php-tokenizer php-xml php-pdo php-json

Install MySQL

Install MySQL server.

dnf install mysql-server -y

Enable MySQL.

systemctl enable mysqld.service
systemctl start mysqld.service

Secure the MySQL installation by running the script below:

mysql_secure_installation

When prompted for a root password, choose a safe password and proceed through the installation.

Then login to the MySQL.

mysql -u root -p

Then create a new database user and grant it privileges to the database that you will create.

So Just follow MySQL commands as shown below:

mysql>CREATE DATABASE polr;
mysql>CREATE USER 'unixcop'@'localhost' identified by 'Unixcop7@';
mysql>GRANT ALL PRIVILEGES on polr.* to 'unixcop'@'localhost';
mysql>FLUSH PRIVILEGES;
mysql>exit

Install Polr

Install git.

dnf install git -y

Then clone the Polr repo from Github.

cd /var/www/html 
git clone https://github.com/cydrobolt/polr.git --depth=1

Transfer the downloaded files to the root of web server.

mv ./polr/.[!.]* . && mv ./polr/* . && rm -rf polr

Download the Composr with the following command:

curl -sS https://getcomposer.org/installer | php

Also install the dependencies required with php Composr.

php composer.phar install --no-dev -o

Copy the configuration file to enable the web intrface installer.

cp .env.setup .env

Change file with the suitable permissions.

chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/
chcon -R -t httpd_sys_rw_content_t storage .env

Start the web server.

systemctl start httpd

Complete the installation with Web-based Installer

Visit polr.unixcop.com to launch the web-based Polr installer and enter the required information. Use the MySQL credentials that you used to create polr database.

When you finished entering the required info, the Polr installation will be completed.

As shown below in the screenshot.

Conclusion

In this guide, we explained how to install polr open source link shortener.

That’s all.

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook