How to Install Shlink URL Shortener with Nginx on Ubuntu 20.04

How to Install Shlink URL Shortener with Nginx on Ubuntu 20.04

MivoCloud

8 месяцев назад

719 Просмотров

Shlink is an open-source and self-hosted URL shortener written in PHP. It is used to generate and manage short URLs from the command line. It allows you to track all visits of your short URLs including, location, browser or referrer. It can be integrated with third-party tools using the Shlink API. It provides a command-line interface to shorten URLs.

In this tutorial, I will show you how to install Shlink on Ubuntu 20.04.

Useful Links:
VPS/VDS - https://www.mivocloud.com/

WARNING - ANGLED BRACKETS AREN'T ALLOWED IN DESCRIPTION SO BE ATTENTIVE TO THE VIDEO IN NANO EDITOR

Commands Used:
apt-get install nginx mariadb-server php-apcu php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-common php7.4-curl php7.4-intl php7.4-gmp php7.4-xml php-dev php-pear unzip -y
mysql
CREATE DATABASE shlink;
GRANT ALL ON shlink.* TO 'shlink'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
wget https://github.com/shlinkio/shlink/releases/download/v2.7.1/shlink2.7.1_php7.4_dist.zip
unzip shlink2.7.1_php7.4_dist.zip
mv shlink2.7.1_php7.4_dist /var/www/html/shlink
chown -R www-data:www-data /var/www/html/shlink/
chmod -R 755 /var/www/html/shlink/
sudo -u www-data php7.4 /var/www/html/shlink/bin/install

nano /etc/nginx/conf.d/shlink.conf

server {
listen 80;
server_name shlink.example.com;

root /var/www/html/shlink/public;
error_log /var/log/nginx/shlink.error;
access_log /var/log/nginx/shlink.access;

index index.php index.html index.htm index.nginx-debian.html;

location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php$is_args$args;
}

# redirect some entire folders
rewrite ^/(vendor|translations|build)/.* /index.php break;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}

nginx -t
systemctl restart nginx
systemctl status nginx
sudo -u www-data php7.4 /var/www/html/shlink/bin/cli short-url:generate
sudo -u www-data php7.4 /var/www/html/shlink/bin/cli short-url:list
sudo -u www-data php7.4 /var/www/html/shlink/bin/cli

Тэги:

#VPS #VDS #Hosting #Servers #Ubuntu #Linux #Debian #Web #Site #Shlink #How_to #Nginx
Ссылки и html тэги не поддерживаются


Комментарии: