惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
D
DataBreaches.Net
腾讯CDC
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
罗磊的独立博客
月光博客
月光博客
MyScale Blog
MyScale Blog
U
Unit 42
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
G
Google Developers Blog
博客园 - 【当耐特】
D
Docker
I
InfoQ
雷峰网
雷峰网

eallion's Blog

春假清明自驾游 Ubuntu 25.10 安装和配置 秋假 彩礼 2025 博客变化 预制菜 联邦礼仪之一 重拾写博客的乐趣 少儿 TED - 时间管理大师 n8n 之同步博客到 Mastodon n8n 之备份 Mastodon 嘟文 如何备份 Mastodon Docker 部署 Mastodon NAS 折腾记 Windows 11 安装软件 博客排版 - 挤压中文标点符号 Hugo 博客集成 Mastodon 独立博客自省问卷 15 题 Chrome 插件更新:网址净化器 在 Hugo 中使用 Shiki 炒菜万能公式 uBlacklist 订阅合集 读《中文互联网正在加速崩塌》 CSS 和 JS 实现博客热力图 受灾小记 那,他吃什么?! Mastodon 同步到 Memos Hugo 外部链接跳转提示页面 联邦宇宙及 Mastodon 简介 2024 博客变化
短链接 url 压缩程序 Polr
Charles Chin · 2017-04-09 · via eallion's Blog

开源项目地址: https://github.com/Cydrobolt/polr

案例:

我一直在用这个短链接压缩程序,最近刚好有朋友问到,就写一下教程。
其实很简单,虚拟主机都能安装,但是推荐用 vps 安装,因为虚拟主机只能使用 1.5.1 版本。

Oneinstack LNMP 为例

  • Apache, nginx, IIS, or lighttpd (作者建议使用 Apache,我是使用的 Nginx)

  • PHP >= 5.5.9

  • MariaDB or MySQL >= 5.5, SQLite 三个都可以

  • composer

  • PHP 扩展:

    • OpenSSL
    • PDO
    • php5-mysql
    • Mbstring
    • Tokenizer
    • JSON
# 切换到 root
sudo su 
# 假设准备使用的域名是 go.eallion.com,网站根目录:/data/wwwroot/go.eallion.com
cd /data/wwwroot/go.eallion.com 
# git 下载源码
git clone https://github.com/cydrobolt/polr.git --depth=1 
# 设置权限
chmod -R 755 polr
chown -R www:www polr
cd polr
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev -o

如果没有 php5-fpm,则需要安装

apt install php5-fpm
# 配置网站配置文件
vim /usr/local/nginx/conf/vhost/go.eallion.com.conf

我的配置:

upstream php {
    server unix:/var/run/php5-fpm.sock;
    server 127.0.0.1:9000;
}
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /usr/local/nginx/conf/ssl/go.eallion.com.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/go.eallion.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name go.eallion.com;
access_log /data/wwwlogs/go.eallion.com_nginx.log combined;
index index.html index.htm index.php;
root /html/go.eallion.com/polr/public; #注意要配置到 public 目录
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
    valid_referers none blocked *.go.eallion.com go.eallion.com www.go.eallion.com;
    if ($invalid_referer) {
        #rewrite ^/http://www.linuxeye.com/403.html;
        return 403;
        }
    }
location ~ [^/]\.php (/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
    expires 30d;
    access_log off;
    }
    location / {
            try_files $uri $uri//index.php$is_args$args;
            # rewrite ^/([a-zA-Z0-9]+)/?$ /index.php?$1;
    }

    location ~ \.php$ {
            try_files $uri =404;
            include /usr/local/nginx/conf/fastcgi_params;

            fastcgi_pass    php;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param   HTTP_HOST       $server_name;
    }
location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
    }
CREATE DATABASE polrdatabasename;

其实用 phpMyAdmin 更方便。

先复制一个.env 文件

因为一直是在 root 账号下操作,安装之前再修改一下权限

chown -R www:www /data/wwwroot/go.eallion.com/polr

然后就可以在线安装了
打开域名,如: https://go.eallion.com
会自动跳转到安装页面,按提示一步步完成就可以了。