Debian11搭建YOURLS+Caddy2自己的短链接服务 2023-06-28 学习笔记,倒腾笔记 暂无评论 186 次阅读 ## 介绍 YOURLS是一组 PHP 脚本,允许您使用您选择的域或子域在您的服务器上运行您自己的URL缩短器。 您将完全控制您的数据、详细统计数据、分析、插件等。 它是免费且开源的。 ## 要求 YOURS 有以下要求: ### 服务器 - [Apache (httpd)](https://httpd.apache.org/)版本2.4或更高版本,已`mod_rewrite`启用,或者Nginx、Caddy2。 - [PHP](https://secure.php.net/)版本**7.4**或更高版本 - 如果您打算使用 API,则需要PHP [cURL扩展](https://www.php.net/curl) - [MySQL](https://www.mysql.com/)版本**5.0**或更高版本,或者[MariaDB](https://mariadb.org/)版本**10.0**或更高版本。 **我们还建议您使用支持HTTPS 的**主机。 如果您要安装自己的服务器,请参阅[此文件](https://github.com/YOURLS/YOURLS/blob/master/composer.json)以了解 YOURLS 将使用的 PHP 扩展。 ### 客户端 任何现代网络浏览器都可以。 ## 安装 安装和更新 YOURLS 是一项简单的任务。一些主机通过 CPanel 等工具提供流程自动化。 先决条件 本文档的这一部分假定您基本熟悉软件部署或系统管理。如果您对 Web 应用程序管理完全陌生,那么作为第一步直接跳入该项目可能不是最好的主意 - 掌握基础知识然后再回来! ## 手动说明 1. 获取[最新版本存档](https://github.com/YOURLS/YOURLS/releases) ``` cd /www wget https://github.com/YOURLS/YOURLS/archive/refs/tags/1.9.2.zip ``` "1.9.2.zip"按实际版本号修改 2. 解压 YOURLS 存档 ``` unzip 1.9.2.zip ``` 3. 复制`user/config-sample.php`到`user/config.php` ``` cd YOURLS_1.9.2 cp user/config-sample.php user/config.php ``` 4. 修改设置[本地语言](https://github.com/YOURLS/awesome) [简体中文](https://github.com/taozhiyu/yourls-translation-zh_CN) - 在 `config.php` 添加或编辑以下行: `define( 'YOURLS_LANG', 'zh_CN' );` - 下载[简体中文https://github.com/taozhiyu/yourls-translation-zh_CN](https://github.com/taozhiyu/yourls-translation-zh_CN)最新版`wget https://github.com/taozhiyu/yourls-translation-zh_CN/archive/refs/tags/V1.9.2.zip` - 解压`unzip yourls-translation-zh_CN-1.9.2.zip user/languages/`到 `user/languages`, 两个文件`zh_CN.po` 和`zh_CN.mo` 4. 填写`user/config.php`所需的设置 ``` nano user/config.php ``` 'password', // 'username2' => 'password2', // You can have one or more 'login'=>'password' lines ]; /** URL shortening method: either 36 or 62 ** 36: generates all lowercase keywords (ie: 13jkm) ** 62: generates mixed case keywords (ie: 13jKm or 13JKm) ** For more information, see https://yourls.org/urlconvert */ define( 'YOURLS_URL_CONVERT', 36 ); /** Debug mode to output some internal information ** Default is false for live site. Enable when coding or before submitting a new issue */ define( 'YOURLS_DEBUG', false ); /** * Reserved keywords (so that generated URLs won't match them) * Define here negative, unwanted or potentially misleading keywords. */ $yourls_reserved_URL = [ 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', ]; /* ** Personal settings would go after here. */ 5. 创建一个新数据库(请参阅[配置](https://yourls.org/docs/guide/essentials/configuration)\- 您也可以使用现有数据库) 6. 将您的浏览器指向`https://your-own-domain-here.com/admin/` 7. 按照安装程序进行操作 8. Caddy2配置 ``` nano /etc/caddy/Caddyfile ``` ``` # yourls短链接 your-own-domain-here.com { root * /www/path/YOURLS try_files {path} {path}/ /yourls-loader.php file_server php_fastcgi 127.0.0.1:9000 } ``` ## 第三方[指南](https://yourls.org/docs/guide/install#third-party-guides "直接链接到第三方指南") 前往[Awesome YOURLS](https://github.com/YOURLS/awesome-yourls#guides--tutorials)获取覆盖特定环境的安装指南,并翻译成不同的语言。 标签: caddy, YOURLS 本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。