网上找了一圈,各个程序都有自己的想法,不是Golang就是Java,部署就是占用高或者Docker,这不是我想要的。不如找个简单,低占用,DIY以及门槛低的系统程序,所以我找到了YOURLS,用几分钟教大家如何部署。本文非常详细,保姆级别的哦。
YOURLS是一款基于PHP和MySQL的短链生成系统,成熟,自主可控,轻量,功能强大,可自定义,支持api对接(wordpress有对接插件)等 都是它的优势,截至当前拥有11.6k star,开源地址:https://github.com/YOURLS/YOURLS
![图片[1]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008093208472-image.png)
前期准备
使用有PHP和MySQL的系统环境,后面我将使用宝塔面板为大家做演示,记得安装Nginx,MySQL5.0+,PHP8.1+,初次新安装宝塔会推荐你安装的,这里不再赘述。
Foreign friends please refer to: https://www.aapanel.com/
轻量短链接程序部署(PHP/MySQL)
YOURLS的安装流程和常见PHP网站安装差不多,下面将教你如何部署,你也可以查看官方文档:https://yourls.org/docs
打开开源仓库地址,进入最新发行版入口:https://github.com/YOURLS/YOURLS
![图片[2]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094535886-35dab203aec2c8b8ea0a2f99e5f5cbf2.png)
选择其中一个压缩包下载,我下载zip文件
![图片[3]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094635428-fd9d1f844ae9e29f6d1cd3a9ebe4d211.png)
在宝塔创建网站,填写域名并开启MySQL
![图片[4]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094726754-47d5565df5c5f147d8c7ddae20eebfdb.png)
进入创建好的网站根目录
![图片[5]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094842571-fcdbcc678cd530e966376bf70af58cb8.png)
删除目录下的文件,如图剩余的文件所示,上传之前下载的压缩包
![图片[6]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094908951-c32a260b898ba449e567d9c80417746a.png)
上传1(这本不用教的,快谢谢我)
![图片[7]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008094958308-4d875f67955c1d4f770c2ea5ee7dd2a7.png)
上传2
![图片[8]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095031892-c16f12ac11b106aff09b81200d9cd543.png)
解压文件
![图片[9]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095103973-63a43bc862eb6cd71955224fb496b514.png)
进入解压出来的文件
![图片[10]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095118912-6e578a8c4640c981963151b17984372b.png)
全选,剪切
![图片[11]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095146675-ca9b81e69485736de05027f6e34e2763.png)
回到网站根目录,将剪切的文件粘贴到这里
![图片[12]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095210818-d8c42d6bff2af695194e7faa99ea7cad.png)
YOURLS Config配置
在user文件夹中新建config.php
config.php中文版注释配置:
![图片[13]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095301560-6bbeadf0f1120f7a89e307a6f34e0ec4.png)
将config-sample.php中的代码复制到刚刚创建的config.php文件中
![图片[14]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095358445-8e611cb1565488f9295944ebe1e8361a.png)
现在我们来配置它,在数据库中复制之前创建的网站数据库
![图片[15]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095529991-a4139905a46f616155c018945ccff026.png)
在配置文件中填写,在宝塔中数据库名和用户名一致,密码也只有一个,复制后粘贴,数据库host地址改为127.0.0.1,这样更快,因为默认的方法需要解析,但最终解析结果依旧是127.0.0.1,如果你的数据库在其他IP地址,注意修改
![图片[16]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095637646-ba5b1ef5c72fdef012ac585bc17d14d7.png)
设置你的网址并注意协议,语言设置为zh_CN
![图片[17]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008100554840-image.png)
![图片[18]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008095921566-a3b91e1e32673e65473bc2fdb9f1b126.png)
填写至YOURLS_COOKIEKEY,其次还有设置后台账号密码
![图片[19]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008100031536-d81ee0c4f90655e1a96ce5d552ea1a0c.png)
配置就设置好了
![图片[20]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008100750977-31339397c22ddb714fb06fdede13bb0e.png)
YOURLS 中文语言包安装方法
之前我们已经在配置文件中设置了语言,但没有语言文件支持是不行的
前往:https://github.com/YOURLS/awesome#Translations,选择简体中文,进入翻译文件下载页
![图片[21]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008100212475-c63e02baf4184b2210f66f31065a1e23.png)
在该仓库下载翻译文件
![图片[22]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008100418416-3c105ad68b271f88638740a97f2018f2.png)
上传至/user/languages目录并解压
![图片[23]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101023344-e21c3395e35bec0fc8fea1cf1939935e.png)
剪切.mo和.po文件
![图片[24]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101105569-923e6ea25ffb026c00074f3210273a08.png)
回到语言目录/user/languages粘贴
![图片[25]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101148781-6a9d8bf7450f33e4e17d23e8f11dc53e.png)
现在你的网站已经展示为中文了
YOURLS主题设置教程(Sleeky主题)
初始后台是比较简陋的,也没有前台
你可以在:https://github.com/YOURLS/awesome#Themes,选择主题,我选择Sleeky主题,进入主题仓库
![图片[26]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101925900-image.png)
在主题仓库下载主题压缩包,这里下载方式一般与右下角的发行版下载的代码应该是一致的
![图片[27]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101947320-6102d99d3d30a00549a6ab90492ce61b.png)
上传至网站根目录并解压
![图片[28]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102055169-e52a0cab3af063cb27571b694d7bca29.png)
进入解压出来的目录,选择sleeky-backend目录,剪切这个插件
![图片[29]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102140839-5c4fcc255a591d2b554ea2f45eb508c9.png)
进入插件目录/user/plugins粘贴
![图片[30]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102345359-aece8a58d3259efde5f3393308e47a03.png)
回到解压目录,进入sleeky-frontend前台文件目录并剪切
![图片[31]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102424886-b4e240443144633e6a7c96b4d3dce5f8.png)
在网站根目录粘贴前台文件
![图片[32]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102529468-98f293a9772ff41a8d14397249f5130b.png)
你可以前往目录frontend,对主题进行编辑,基础配置,语言修改,美化自定义等
中文版配置:
![图片[33]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008103552964-image.png)
至此,你拥有了新的主题,当然还需要激活,我们需要在网站后台设置,继续往下看吧
宝塔面板配置YOURLS伪静态与SSL 配置
打开网站设置
![图片[34]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101308802-e51989cc6de9b7cdcbed7f99e1e176a3.png)
在伪静态设置填写以下Nginx配置
location / {
try_files $uri $uri/ /yourls-loader.php$is_args$args;
# 如果YOURLS安装在Windows中,请更改路径
# 到yourls-loader.php,例如, eg
# try_files $uri $uri/ /subdir/yourls-loader.php$is_args$args;
}
![图片[35]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101319384-5d103f3ef7846a7ef8210bd808ff9324.png)
你也可以SSL证书,设置后就可以以安全链接https协议访问你的网址,你也可以找站长我购买证书,前提是你是域名拥有者
![图片[36]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008101409620-1ef8b17cf331bea514f7333c4ee66777.png)
YOURLS 安装与启动插件
在浏览器输入域名/admin,自动进入安装页
![图片[37]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102941720-1b6e4cf4ee6e825dc2f39244fe6a22a6.png)
安装后进入后台登录页
![图片[38]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008103016988-a7d9355e43029071350c2802706b6b5f.png)
填写之前你在配置文件中填写的账号密码,并登录
![图片[39]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008103043725-8d28de5ad3517a49b6ec7734b034714d.png)
进入管理插件,激活主题
![图片[40]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008102912840-78d53383e45f561e0312d29884a2fe0c.png)
此时的后台
![图片[41]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008103219170-809ec3f94e56c97b24fc66874ffb493b.png)
此时的前台
![图片[42]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008103242611-eaff67f95bfb9b2c63dc1db4ac634d12.png)
YOURLS 插件安装示例(Referer Restrict)
安装一款插件很简单,下面教你安装我做的一款插件,开源地址:https://github.com/twsh0305/referer-restrict
用于限制来源防止盗用链接,点个star呗
下载插件压缩包
![图片[43]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008104045708-image.png)
上传到插件目录/user/plugins并解压
![图片[44]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008104307727-image.png)
在网站后台进入管理插件,激活插件
![图片[45]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008104403966-image.png)
激活后,左侧即可进入插件设置
![图片[46]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008104527107-image.png)
YOURLS API 构建步骤
请求地址:http://域名//yourls-api.php 参数:username(用户名)、password(密码)、format(格式 json)、url(长地址)、action(功能,shorturl)
例如:
http://url.link/yourls-api.php?username=user&password=password&url=http://www.baidu.com&format=json&action=shorturl
![图片[47]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008105443147-image.png)
其它方式见工具
![图片[48]-在宝塔面板安装一个很受欢迎的短链接网站开源程序YOURLS-王先生笔记](https://wxsnote.cn/wp-content/uploads/2025/10/20251008105825867-image.png)
结语
至此,我写完了这篇文章,你可能只需要几分钟就完成了所有操作,而我写文章用了几个小时,点个赞吧,谢谢。打赏一些也好。
精心挑选的与YOURLS相关的精彩事物列表:https://github.com/YOURLS/awesome
翻译插件:https://github.com/8Mi-Tech/yourls-i18n-manager(啊哈哈哈哈,鸡汤来喽)
2025-10-30 20:13:56,某些文章具有时效性,若有错误或已失效,请在下方留言或加入QQ群:
399019539 联系群主反馈。注意一些链接无法访问可能是你网络的原因,如Github,并非资源地址失效。
登录后可快速点此处反馈,点击登录














请登录后查看评论内容