YOURLS是一款国外的开源短网址程序,功能够用,简洁,支持插件化扩展,也支持API调用,提供书签栏快捷缩短网址服务。
之前网上找了一下,目前最新版是1.7.2版,但没有对应的汉化语言文件,有的也是老版本的,新版很多文字没有翻译,因此花了点时间进行汉化。
下面说说下载安装配置相关步骤
1、下载YOURLS源程序,解压。下载地址:https://github.com/YOURLS/YOURLS/releases
2、下载安装简体中文语言包,下载地址:https://github.com/shileiye/YOURLS-zh-CN.pot
3、复制 user/config-sample.php 为 user/config.php
4、使用文本编辑器(如记事本)打开 user/config.php 填写数据库+用户+语言设置,参考下面的config.php配置
5、将解压缩的文件上传到您的域public_html或www文件夹
6、创建一个数据库(请参阅配置 – 您也可以使用现有的数据库)
7、配置Nginx文件,参考下面的Nginx配置
8、打开浏览器访问 http://your-domain.com/admin/
config.php配置参考
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <?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-domain-dbuser' ); /** MySQL database password */ define( 'YOURLS_DB_PASS', 'your-domain-dbuser-password' ); /** The name of the database for YOURLS */ define( 'YOURLS_DB_NAME', 'your-domain-dbname' ); /** 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 and with no trailing slash.  ** If you define it to "http://sho.rt", don't use "http://www.sho.rt" in your browser (and vice-versa) */ define( 'YOURLS_SITE', 'http://your-domain.com' ); /** Server timezone GMT offset */ define( 'YOURLS_HOURS_OFFSET', 8 );  /** 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', 'zh_CN' );  /** 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', 'faderdfg1wegfwe5146weg6gds131sdg4165sd41g' ); /** 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( 	'admin' => 'user-password' /* Password encrypted by YOURLS */  /* Password encrypted by YOURLS */ , 	// 'username2' => 'password2', 	// You can have one or more 'login'=>'password' 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', 62 ); /*  * 36: generates all lowercase keywords (ie: 13jkm)  * 62: generates mixed case keywords (ie: 13jKm or 13JKm)  * Stick to one setting. It's best not to change after you've started creating links.  */ /**  * Reserved keywords (so that generated URLs won't 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.  */ | 
Nginx的HTTP配置
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | server {     listen                     80;     server_name                your-domain.com;     root                       /www/your-domain.com;     index                      index.html index.htm index.php;     location / {         try_files  $uri $uri/ /yourls-loader.php;     }     location ~ ^/.+\.php {         fastcgi_index            index.php;         fastcgi_split_path_info  ^(.+\.php)(.*)$;         fastcgi_param            SCRIPT_FILENAME $request_filename;         fastcgi_param            PATH_INFO $fastcgi_path_info;         fastcgi_param            PATH_TRANSLATED $document_root$fastcgi_path_info;         include                  fastcgi_params;         fastcgi_pass             127.0.0.1:9000;     } } | 
Nginx的HTTP+HTTPS配置
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | server {     listen                     443;     listen                     80;     server_name                your-domain.com;     root                       /var/www/your-domain.com;     index                      index.html index.htm index.php;     keepalive_timeout          90s;     client_max_body_size       10m;     ssl                        on;     ssl_certificate            /ssl/your-domain.com/your-domain.com.crt;     ssl_certificate_key        /ssl/your-domain.com/your-domain.com.key;     ssl_ciphers                ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;     ssl_prefer_server_ciphers  on;     ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;     ssl_session_cache          shared:SSL:5m;     ssl_session_timeout        5m;     location / {         try_files  $uri $uri/ /yourls-loader.php;     }     location ~ ^/.+\.php {         fastcgi_index            index.php;         fastcgi_split_path_info  ^(.+\.php)(.*)$;         fastcgi_param            SCRIPT_FILENAME $request_filename;         fastcgi_param            PATH_INFO $fastcgi_path_info;         fastcgi_param            PATH_TRANSLATED $document_root$fastcgi_path_info;         include                  fastcgi_params;         fastcgi_pass             127.0.0.1:9000;     } } | 
