قالب وردپرس درنا توس
Home / How To / How to install Polr Link Shortener on Debian 10

How to install Polr Link Shortener on Debian 10



Polr is a free and open source URL for URL that lets you host your own link shortener. It is written in PHP and Lumen and uses MariaDB to store its data. With Polr you can create new links or look up existing links without breaking your existing code.

In this tutorial, we will show you how to install the Polr Link Shortener software on the Debian 10 server.

Prerequisites

  • A server running Debian 10.
  • A valid domain name pointed to your server IP. in this tutorial we will use the polr.example.com domain.
  • A root password is configured on your server.

Getting Started

Before you begin, it is a good idea to update your system with the latest version. You can update your system with the following command:

  apt-get update -y 
apt-get upgrade -y

After updating the system, restart it to implement the changes.

Installing LAMP Server [1
9659008] First you need to install Apache web server, MariaDB server, PHP and other packages in your system. You can install all with the following command:

  apt-get install apache2 mariadb server libapache2-mod-php php php-pdo php-mysql php-mbstring php-tokenizer php-json php-curl git wget unzip - y [19659010] Once all packages have been installed, launch Apache and MariaDB service and allow them to boot after system restart. 

  systemctl start apache2 
systemctl start mariadb
systemctl enable apache2
systemctl enable mariadb

When you are finished, you can proceed to the next step.

Configuring MariaDB Database

By default, the MariaDB root password is not configured in Debian 10. So you have to set it first. [19659002] To do so, log in to the MariaDB shell with the following command:

  mysql 

When logged in, set your MariaDB root password with the following command:

  MariaDB [(none)]> SET PASSWORD FOR ROOT & # 39; @ & # 39; localhost & # 39; = PASSWORD ("new password"); 

Then create a database and user for Polr wit h the following command:

  MariaDB [(none)]> CREATE DATABASE polrdb; 
MariaDB [(none)]> ASK ALL ON polrdb. * ON & # 39; polar & # 39; IDENTIFIED OF & # 39; password & # 39 ;;

Then flush the privileges and exit from the MariaDB shell with the following command:

  MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;

When you're done, you can move on to the next step.

Installing Composer

Then you must install Composer on your system. Composer is a PHP dependency manager used to install all PHP dependencies for your project.

First load Composer with the following command:

  php -r "copy (& # 39; https: //getcomposer.org/installer', & # 39; composer-setup.php & # 39;); "

Next, you must verify the data integrity of the downloaded script by comparing the SHA-384 hash script with the latest hash.

To do so, download the signature for the latest Composer installer from the Git repository and store it in a variable named HASH:

  HASH = "$ (wget -q -O - https: // composer .github.io / installer.sig) "Chapter19659010] Then verify the installation script with the following command: 

  php -r" if (hash_file (& # 39; SHA384 & # 39 ;, & # 39; composer-setup.php & # 39 😉 === & # 39; $ HASH & # 39;) {echo & # 39; install verified & # 39 ;;} else {echo & # 39; install corrupt & # 39 ;; unlink (& # 39; composer-setup .php & # 39;);} echo PHP_EOL; "

If the hashes match, you will see the following output:

  Installer verified

Finally, install Composer with the following command:

  php composer-setup.php --install-dir = / usr / local / bin --filename = composer 

When the installation is complete, you should see the following output:

  All settings that are correct for using Composer
Downloading...
Composer (version 1.9.2) is successfully installed for: / usr / local / bin / composer
Use it: php / usr / local / bin / composer

When you're done, you can move on to the next step.

Install Polr

First download the latest version of Polr from the Git repository to the Apache web root directory:

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

After downloading, change the directory to polr and install all necessary dependencies with the following command: [19659009] cd polr
composer install --no-dev -o [19659010] Next, activate the web-based installer by renaming the following file:

  etc.env.setup .env 

Then you give the correct permissions to the polar directory as shown below:

  chown-R www-data: www-data / var / www / html / polr / 
chmod -R 755 / var / www / html / polr /

Once you are done, you can proceed to the next step.

Configuring Apache for Polr

Next, you need to create an Apache virtual host configuration file for Polr. You can create it with the following command:

  nano /etc/apache2/sites-available/polr.confospel19659010??Add the following lines: 

  
ServerAdmin [email protected]
DocumentRoot / var / www / html / polr / public
Server name polr.example.com


Alternative FollowSymlinks
AllowOrrride All
Require everyone granted


ErrorLog $ {APACHE_LOG_DIR} /polr_error.log
CustomLog $ {APACHE_LOG_DIR} /polr_access.log combined


Save and close the file when you are done. Then enable Apache virtual host file and rewrite the module with the following command:

  a2ensite polr.conf 
a2enmod rewrite

Restart the Apache service to implement the changes:

  systemctl restart apache2 [19659010] At this point is installed and configured Polr. You can now proceed to the next step. 

Access Polr Web Interface

Now open your browser and type the URL http://polr.example.com . You will be redirected to the Polr Setup Wizard as shown below:

 Polr Database Configuration

 Application Settings

 Admin account

 reCaptcha Settings

Enter your database information, application settings, administrator account settings and click the Install button. When the installation is complete, see the following page:

 Polr Setup Complete

Click the login button . You will be redirected to the Polr login page:

 Polr login

Enter your username, password and click the LOGIN button. You should see the following page:

 Polr link shortener

 Shorten links

Now click on ADMIN => DASHBOARD in the upper right corner. You should see the Polr dashboard on the following page:

 Admin Dashboard

Secure Polr with Let & # 39; s Encrypt Free SSL

First you need to install the Certbot Let & # 39; s Encrypt client to Download and install SSL certificates for your domain.

You can install it with the following command:

  apt-get install python-certbot-apache -y 

Once installed, you can run the following command to install Let's # Encrypt Certificate for your domain polr.example.com.

  certbot --apache -d polr.example.com 

During installation, you will be prompted to enter your email address and accept the service shown below:

  Saves troubleshooting log to / var / log / letsencrypt / letsencrypt .log
Selected plugins: Authenticator apache, Install apache
Enter Email Address (Used for Emergency Renewal and Security Messages) (Enter & # 39; c & # 39; to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Read the terms of use at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree to register on the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A) gree / (C) ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Should you be willing to share your email address with Electronic Frontier
Foundation, a founding partner of Let & # 39; s Encrypt project and the nonprofit
organization developing Certbot? We want to send an e-mail about our work
web encryption, EFF news, campaigns and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y) es / (N) o: Y
Get a new certificate
Perform the following challenges:
http-01 challenge for polr.example.com
Activated module for rewriting Apache
Waiting for verification ...
Cleaning of challenges
Created an SSL vhost at /etc/apache2/sites-available/polr-le-ssl.conf
Distribute certificates to VirtualHost /etc/apache2/sites-available/polr-le-ssl.conf
Activate available site: /etc/apache2/sites-available/polr-le-ssl.conf

Choose whether to redirect HTTP traffic to HTTPS or remove HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No Redirect - Do not make any further changes to the web server configuration.
2: Redirect - Makes all requests redirect to secure HTTPS access. Select this for
new websites, or if you are sure your site is working on HTTPS. You can undo this
change by editing your web server configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] and then [enter] (press & # 39; c & # 39; to cancel): 2

Then enter 2 and hit Enter to download and install a free SSL certificate for your domain. When the installation is complete. You should get the following output:

  Enabled Apache rewrite module
Redirect vhost in /etc/apache2/sites-enabled/polr.conf to ssl vhost in / etc / apache2 / sites-available /
POLR-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have enabled https://polr.example.com

You should test your configuration on:
https://www.ssllabs.com/ssltest/analyze.html?d=polr.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Your Polr site is now secure with Let & # 39; s Encrypt free SSL. You can access it with the URL https://polr.example.com .

Conclusion

Congratulations! you have installed Polr on the Debian 10 server and secured it with Let & # 39; s Encrypt SSL. You can now host your own link shortener with the Polr web interface. Feel free to ask me if you have any questions.


Source link