找回密码
 立即注册

[完结] yourls_ v1.10.2 短域名系统 +年份十进制增量规则

[复制链接]
69伙伴 发表于 2020-3-30 22:54:13 | 显示全部楼层 |阅读模式

更新日期

admin-dashboard.gif

stats-anim.gif

用yourls 搭建短链接地址服务
疫情期间没事瞎折腾,索性就研究了下yourls 。
发现这个玩意功能挺强大的,不但可以批量生成自己的短地址,还可以管理,统计每个短地址点击数量,还可以提供api接口。
最重要的是,这个开源免费

下载地址
https://github.com/YOURLS/YOURLS/releases

自家用完全无敌了。
1、将user目录下的config-sample.php 重命名 为 config.php
2、修改config.php里面的配置参数

  1. define( 'YOURLS_DB_USER', 'root' );
  2. define( 'YOURLS_DB_PASS', '123456' );
  3. define( 'YOURLS_DB_NAME', 'yourls' );
  4. define( 'YOURLS_DB_HOST', 'localhost' );
  5. define( 'YOURLS_DB_PREFIX', 'yourls_' );
  6. //上面是数据信息不用多说
  7. define( 'YOURLS_SITE', 'http://test.com' ); //你自己服务器的域名 用最短的,短地址也是基于这个生成。
  8. define( 'YOURLS_HOURS_OFFSET', '+8');    //时区偏移 
  9. define( 'YOURLS_LANG', 'zh_CN' );      //这个语言默认是英文,没有中文包,需要自己去 [url]https://github.com/guox/yourls-zh_CN/[/url]下载,放到 user/languages 里面 
  10. define( 'YOURLS_UNIQUE_URLS', true );   //短地址是否唯一 
  11. define( 'YOURLS_PRIVATE', true );         //是否私有,如果私有的,则进行api调用生成短地址时需要传递用户名和密码
  12. define( 'YOURLS_COOKIEKEY', 'A2C7&H~r80pTps{nIfI8VFpTxnfF3c)j@J#{nDUh' );//加密cookie 去 [url]http://yourls.org/cookie[/url] 获取
  13. $yourls_user_passwords = array(
  14.     'admin' => '123456' /* Password encrypted by YOURLS */ ,  //用户名=>密码  可填多个  登录成功后这里的明文密码会被加密
  15.     );
  16. define( 'YOURLS_DEBUG', false );      //是否开启调试  
  17. define( 'YOURLS_URL_CONVERT', 36 );    //使用36进制 还是62进制  
  18. $yourls_reserved_URL = array(
  19.     'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick',  //排除一下短地址,这些地址是不会生成的
  20. );
复制代码

nginx 配置里添加

  1.   # Rewrites  主要看这一项配置就够了,路由重写
  2.   location / {
  3.     try_files $uri $uri/ /yourls-loader.php$is_args$args;
  4.   }

  5. ------
  6. server {

  7.   # HTTP over IPv4 & IPv6
  8.   listen 80;
  9.   listen [::]:80;

  10.   # HTTPS over IPv4 & IPv6
  11.   listen 443 ssl;
  12.   listen [::]:443 ssl;
  13.   ssl_certificate     example.com.crt;
  14.   ssl_certificate_key example.com.key;

  15.   server_name example.com [url]www.example.com[/url];

  16.   # Root directory
  17.   root /path/to/yourls/files;

  18.   # Rewrites  主要看这一项配置就够了,路由重写
  19.   location / {
  20.     try_files $uri $uri/ /yourls-loader.php$is_args$args;
  21.   }

  22.   # PHP engine
  23.   location ~ .php$ {
  24.     include fastcgi.conf;
  25.     # include fastcgi_params;
  26.     fastcgi_index index.php;
  27.     fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
  28.   }

  29. }


复制代码


、如果提示504 url过长的话,则在nginx增加

  1.     client_max_body_size 5m;
  2.     client_header_buffer_size 512k;
  3.     large_client_header_buffers 4 512k;
复制代码


如果遇到 Faithfully yours, nginx.错误,可能是cookies过长,可以看
https://blog.csdn.net/wang_quan_li/article/details/41802643

http字段中添加
  1.     proxy_buffer_size  128k;
  2.     proxy_buffers   32 32k;
  3.     proxy_busy_buffers_size 128k;
复制代码


php配置中添加
  1.         fastcgi_buffer_size 128k;
  2.         fastcgi_buffers 4 256k;
  3.         fastcgi_busy_buffers_size 256k;
复制代码


如果还是不行就在location转发中也添加
  1.     proxy_buffer_size  128k;
  2.     proxy_buffers   32 32k;
  3.     proxy_busy_buffers_size 128k;
复制代码







优化下连接格式


下面的方法 是自家用格式

起始格式 210   220  290 990
年后两位 2021年 取21 +十进制ID递增


本人使用的 十进制 格式  年 2021年 取末尾 21年 + 十进制ID递增
格式:年+0
例 210  //21年第一个   
     220   22 年第一个
     990   22 年第一个   

遇9 添0  为了下次递增 方便进位   否则  就会进位至日期
例 219   21年第一9个
218 --> 2109 -->2110
21998  -->210999 -->211000

制作成了插件,直接激活插件使用, 不用修改 config 配置 中的进制
自己下吧
https://github.com/huoban/plugin ... rement-ID-Generator

推荐一个必备插件,返回404。
https://github.com/YOURLS/404-if-not-found/




官方插件地址  里面还有很多不错的插件
https://github.com/YOURLS/awesome#plugins


放在 \user\plugins里
实用插件总结
快速下载你的插件 (放在 \user\plugins里 新建一个文件夹比如叫down 在吧plugin.php放进去)
https://github.com/krissss/yourls-download-plugin

密码保护您想要的任何短 URL,以便在重定向之前提示用户输入密码。
https://github.com/MatthewC/yourls-password-protection

如何防止 YOURLS 检查更新
https://github.com/YOURLS/YOURLS/issues/2851

热门点击- 显示过去几天点击次数最多的链接的顶部。
https://github.com/miconda/yourl ... gins/popular-clicks

显示在特定时间范围内哪些短链接被点击最多
https://github.com/vaughany/yourls-popular-clicks-extended

在 YOURLS 中创建和显示 QR 码
https://techlister.com/plugins-2/qrcode-plugin-for-yourls/

不计算短 URL 的点击次数。
https://github.com/vipwangtian/yourls-skip-click-count


JSON 响应
https://github.com/tessus/yourls-json-response

临时交流 ⇨点我留言
【附件·直下】非必要·勿注册

联系我们 ( 京ICP备16001788号 ) | 网站地图 | 2012- UID.Cool |

GMT+8, 2025-11-8 14:49

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表