a站是啥,wordpress模版post.php,如何创造属于自己的软件,采集1024图片到wordpress昨天在 YouTube 上看到又一个搭建自己短网址的视频教程#xff0c;用的是开源的 polr#xff0c;但是按照步骤一步步搭建下来#xff0c;最后一步都会出现
顺哥轻创
PLAINTEXT Whoops, looks like something went wrong百度、谷歌查了一圈也没找到有效的解决方法。#x…昨天在 YouTube 上看到又一个搭建自己短网址的视频教程用的是开源的 polr但是按照步骤一步步搭建下来最后一步都会出现
顺哥轻创
PLAINTEXT Whoops, looks like something went wrong百度、谷歌查了一圈也没找到有效的解决方法。顺带说一下查出来很多的文章都是出自同一个作者国内有的人就是瞎转载自己根本没有尝试过一个人错了转载的人也跟着一起错完全在浪费搜索者的时间这个现象在百度、CSDN 现尤为严重谷歌相对好一点
折腾了一晚上换了两台服务器查看官方文档尝试了几种方法也没解决问题心里非常不舒服。 考虑到 polr 也很久没有更新了自己的能力也不足以解决遇到的 bug而工作原因确实对点击链接的统计有需求我开始寻找别的解决方案。
然后找到了这个 ——YOURLS 官方文档https://yourls.org 简单介绍
什么是 YOURLS
YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or Bitly).
Running your own URL shortener is fun, geeky and useful: you own your data and don’t depend on third-party services. It’s also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
大概意思就是说 YOURLS这个基于 PHP 开发的短链接服务适用于私有且不依赖第三方公共短链接生成。你只需要有一定的耐心和一个短域名就可以感受到短链接生成的乐趣。
特点
免费而且开源使用具有两面性私有的仅自己使用或者生成公共的每个人都可以创建短链接适用于 Intranet顺序排列 (从 1 到 n) 或自定义 URL 关键字十分方便的类书签模式记录可轻松缩短和共享链接出色的统计信息历史点击报告引荐来源跟踪访问者地理位置整洁的 Ajaxed 界面出色的插件架构可轻松实现新功能支持开发人员 API全面的 jsonp 支持安装十分友好示例文件可创建您自己的公共界面等
跟着官方文档和 Pluto Tz 提供的文章结合自己的生产环境我终于成功搭建好了自己的短链接服务。
展示链接
下面是一步一步的安装记录。
安装环境 系统 Centos7 宝塔面板LNMP Nginx 1.16.1MySQL 5.5.62PHP 7.0
新建站点
首先打开宝塔面板我们来添加一个已经解析好的网站。
安装数据库php。 然后给域名申请一个 SSL 证书 开启强制 https 设置伪静态
PLAINTEXT location / {try_files $uri $uri/ /yourls-loader.php$is_args$args;
}下载源码
到 github 上下载最新版本
https://github.com/YOURLS/YOURLS/releases
目前最新的是 1.7.9 选择下载国内速度比较慢不过好在文件不大只有 2.7M 当然如果我们的服务器不在大陆的话还可以用服务器来下载速度会快很多。
方法如下
打开网站根目录 下载好了之后直接点解压 打开 YOURLS-1.7.9 文件夹全选里面的内容粘贴到网站根目录 接下来打开目录 /user/, 把里面的 config-sample.php 改成 config.php。 然后我们来编辑里面的内容 打开之后是这样的
PLAINTEXT ?php
/* This is a sample config file.* Edit this file with your own settings and save it as config.php** IMPORTANT: edit and save this file as plain ASCII text, using a text editor, for instance TextEdit on Mac OS or* Notepad on Windows. Make sure there is no character before the opening ?php at the beginning of this file.*//*** MySQL settings - You can get this info from your web host*//** MySQL database username */
define( YOURLS_DB_USER, your db user name );/** MySQL database password */
define( YOURLS_DB_PASS, your db password );/** The name of the database for YOURLS */
define( YOURLS_DB_NAME, yourls );/** MySQL hostname.** If using a non standard port, specify it like hostname:port, eg. localhost:9999 or 127.0.0.1:666 */
define( YOURLS_DB_HOST, localhost );/** MySQL tables prefix */
define( YOURLS_DB_PREFIX, yourls_ );/*** Site options*//** YOURLS installation URL -- all lowercase, no trailing slash at the end.** If you define it to http://sho.rt, dont use http://www.sho.rt in your browser (and vice-versa) */
define( YOURLS_SITE, http://your-own-domain-here.com );/** Server timezone GMT offset */
define( YOURLS_HOURS_OFFSET, 0 ); /** YOURLS language** Change this setting to use a translation file for your language, instead of the default English.** That translation file (a .mo file) must be installed in the user/language directory.** See http://yourls.org/translations for more information */
define( YOURLS_LANG, ); /** Allow multiple short URLs for a same long URL** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define( YOURLS_UNIQUE_URLS, true );/** Private means the Admin area will be protected with login/pass as defined below.** Set to false for public usage (eg on a restricted intranet or for test setups)** Read http://yourls.org/privatepublic for more details if youre unsure */
define( YOURLS_PRIVATE, true );/** A random secret hash used to encrypt cookies. You dont have to remember it, make it long and complicated. Hint: copy from http://yourls.org/cookie **/
define( YOURLS_COOKIEKEY, modify this text with something random );/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes** YOURLS will auto encrypt plain text passwords in this file** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords array(username password,// username2 password2,// You can have one or more loginpassword lines);/** 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 );/*** URL Shortening settings*//** URL shortening method: 36 or 62 */
define( YOURLS_URL_CONVERT, 36 );
/** 36: generates all lowercase keywords (ie: 13jkm)* 62: generates mixed case keywords (ie: 13jKm or 13JKm)* Stick to one setting. Its best not to change after youve started creating links.*//**
* Reserved keywords (so that generated URLs wont match them)
* Define here negative, unwanted or potentially misleading keywords.
*/
$yourls_reserved_URL array(porn, faggot, sex, nigger, fuck, cunt, dick,
);/*** Personal settings would go after here.*/
下面一条一条来说明
PLAINTEXT define( YOURLS_DB_USER, your db user name ); # 数据库用户名
define( YOURLS_DB_PASS, your db password ); # 数据库密码
define( YOURLS_DB_NAME, yourls ); # 数据库名称
define( YOURLS_DB_HOST, localhost ); # 不用改define( YOURLS_DB_PREFIX, yourls_ ); # 不用改define( YOURLS_SITE, http://your-own-domain-here.com ); # 你自己的域名 越短越好比如我的loll.cc再短的申请不到了。。。短地址基于这个生成。
define( YOURLS_HOURS_OFFSET, 0 ); # 时区偏移 改成 8
define( YOURLS_LANG, ); # 语言设置默认是英文后面我们改成中文版本填zh_CN
define( YOURLS_UNIQUE_URLS, true ); # 不用改短地址是否唯一
define( YOURLS_PRIVATE, true ); # 不用改是否私有如果私有的则进行api调用生成短地址时需要传递用户名和密码
define( YOURLS_COOKIEKEY, modify this text with something random ); # 点击http://yourls.org/cookie 复制里面的密钥,这个不用记住的。
username password, # 用户名密码 可填多个 登录成功后这里的明文密码会被加密这里默认是没有的我们为了安全加上一个比如用户名是admin密码是123456
define( YOURLS_DEBUG, false ); # 不用改,是否开启调试
define( YOURLS_URL_CONVERT, 36 ); # 自己设置使用36进制 还是62进制 这个最好一开始设好不要修改避免地址冲突建议62进制
$yourls_reserved_URL array( porn, faggot, sex, nigger, fuck, cunt, dick,
); # 排除这些敏感词汇这些地址是不会生成的
首先是数据库的相关信息由于我们创建网站的时候已经创建好了数据库所以可以在这边找到数据库的情况 ‘YOURLS_COOKIEKEY’的信息 填完之后保存。 下面我们来安装语言包如果没改成’zh_CN’的话自己想要用英文这一步可以跳过
语音包地址
https://github.com/ZvonimirSun/YOURLS-zh_CN 作者已经停止更新了貌似不过还可以用有能力的同学也可以帮忙翻译。 语音包下载方法同上面讲过的两种方法自行选择。
我这里还是用服务器下载 同样解压然后把 /user/languages/YOURLS-zh_CN-1.7.3 的文件剪切出来 到这里应该基本上已经完成了访问一下
浏览器 输入 https:// 域名 /admin。 报错了
观察网站可能是域名路径的问题我之前在
define( YOURLS_SITE, http://your-own-domain-here.com );
没有加 https://, 修改一下再看看 ok! 直接点击安装 由于我们之前已经配置好的数据库等文件所以这里直接显示完成了。
点击进入管理员页面 输入账号密码就可以访问啦
这边我提供一个测试账号给大家测试一下账号 admin, 密码 loll.cc, 后续会关掉仅仅供测试用噢。 添加一个网址 压缩网址。
之后可以通过在短网址之后加上一个 号来查看数据情况。 可以愉快地玩起来了
补充
这里是来自 PlutoTz 博客的补充内容。
你可能遇到一些问题:
1、如果安装报错或者不跳转那有可能是你的 php 或者 mysql 版本过低
2、短链接后面从 1 开始很不爽可以推荐用时间戳来生成
只需要修改 includes/functions.php 272 行左右
将 $id yourls_get_next_decimal(); 改为 $id time(); 这样的话后面链接会变长而且不知道是 bug 还是什么原因我想改回来改不回来有需要的同学可以尝试一下。 YOURLS 还有很多插件大家有兴趣可以再研究研究。
你可以使用官方自带的插件库
https://github.com/YOURLS/awesome-yourls#plugins
完结撒花。
感谢 PlutoTz 写的非常详细的文档、感谢 YOURLS 提供了这么棒的项目当然还有后面的众多的开发人员。
开源让世界更美好。