锤子 admin
这个人很懒,什么也没留下
废物晚期 老实人
感情交流
jcgzs@vip.qq.com

宝塔nginx 安装YOURLS短网址程序

锤子 · 2个月前
2021-10-8 · 记录 · 65 · 0

 

1.下载好源码和语言包

源码:https://github.com/YOURLS/YOURLS

中文包:https://github.com/guox/yourls-zh_CN/

 

2.宝塔新建网站,需要数据库

3.把源码上传到根目录后,解压,语言包放到/user/languages目录下

4.将user目录config-sample.php 重命名 为 config.php

5.打开config.php,填写下面信息

 

/** 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
 ** Use lower case letters [a-z], digits [0-9] and underscores [_] only 数据库名*/
define( 'YOURLS_DB_NAME', 'yourls' );

/** MySQL hostname.数据库地址
 ** If using a non standard port, specify it like 'hostname:port', e.g. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );

/** MySQL tables prefix
 ** YOURLS will create tables using this prefix (eg `yourls_url`, `yourls_options`, ...)
 ** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
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", don't use "http://www.sho.rt" in your browser (and vice-versa)
 ** To use an IDN domain (eg http://héhé.com), write its ascii form here (eg http://xn--hh-bjab.com) */
define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );

/** YOURLS language 语言包,填 zh_CN
 ** 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 you're unsure */
define( 'YOURLS_PRIVATE', true );  //是否私有

/** A random secret hash used to encrypt cookies. You don't 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 = [
	'username' => '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',
];

6.修改好后,在网站配置文件中修改URL重写规则,修改成下边的

 

    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    try_files $uri $uri/ /yourls-loader.php$is_args$args;

7.访问 域名/admin 进行安装即可,使用config.php填写的账号密码登录即可,如果遇到还是英文等问题,检查config.php填写是否正确。

8.完毕

 

 

参考:https://www.cnblogs.com/myIvan/p/10582849.html

October 08,2021 20:36:52
阅读65
撰写评论