Some friends are interested in the short URL of a good VPS and asked me. Very early on, I shared a wordpress plug-in to implement URL shortening for some longer addresses. Today, I will share it again Share an open source PHP program—YOURLS.
yourls
First, we download the YOURLS source code. The latest version is 1.5. Download it directly from the official website (http://yourls.org/). Then, configure YOURLS.
Open the config-sample.php file under includes and set the following items appropriately:

/** MySQL database username */
define('YOURLS_DB_USER', 'dbuser'); Replace dbuser with your WordPress database username
/** MySQL database password */
define('YOURLS_DB_PASS ', 'dbpassword'); Database password
/** The name of the database for YOURLS */
define('YOURLS_DB_NAME', 'yourls'); Database name
/ ** MySQL hostname */
define('YOURLS_DB_HOST', 'localhost'); Database address
/** MySQL tables prefix */
define('YOURLS_DB_PREFIX', 'yourls _'); yourls is the name prefix of the table to be generated
/** YOURLS installation URL, no trailing slash */
define('YOURLS_SITE', 'http://site.com'); // you The short domain name, which is the domain name bound to the directory you want to install
/** Timezone GMT offset */
define('YOURLS_HOURS_OFFSET', 0); Time zone setting, no need to change
/** 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); Multiple short URLs correspond to the same long address, select true to close the service
/** Private means protected with login/pass as defined below. Set to false for public usage. */
define('YOURLS_PRIVATE', true); Choose public service or private service. Generally, it is for your own use. Select true for private
/** 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', 'qQ4KhL_pu|[email protected]#%:b^{A[vhm'); Customize cookie, no need to change
/** Username(s) and password( s) allowed to access the site */
$yourls_user_passwords = array(
'username' => 'password', replace username and password with the username and password you use to log in to yourls backend respectively
'username2′ => 'password2' // You can have one or more 'login'=>'password' lines
); You can set multiple groups. The replacement method is the same as above. It is best to keep only one group for security reasons.

After configuration, change the file name to config.php, upload it and open http://your short URL/admin/install.php in the browser, follow the steps, its background management The address is: http://your short URL/admin/. Enter a set of account and password you specified to log in (the account password is stored in your config.php file in the form of text).
After completing these tasks, we can log in to generate our own short URL. In addition, YOURLS also has a plugin based on WordPress: YOURLS: WordPress to Twitter. You can also use this plugin to make YOURLS and WordPress work together. The official website has very detailed instructions for use.
Finally, many friends use VPS and use LNMP environment to build their websites. Here are the YOURLS pseudo-static rules.

location /
{
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/([0-9A-Za-z]+)/?$ /yourls-go.php?id =$1 last;
}
rewrite ^/([0-9A-Za-z]+)+/?$ /yourls-infos.php?id=$1 last;
rewrite ^/([ 0-9A-Za-z]+)+all/?$ /yourls-infos.php?id=$1&all=1 last;
}

Hong Kong/United States/Domestic High Speed ​​VPS

Tags: URL shortening, URL shortening, yourls, URL shortening

window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":["mshare","kaixin001","tsina"," tsohu","tqq","renren","qzone","weixin","bdysc","bdxc","tqf","tieba","douban","bdhome","sqq","thx" ],"bdPic":"","bdStyle":"0","bdSize":"24"},"slide":{"type":"slide","bdImg":"2","bdPos" :"left","bdTop":"100"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["tsina","tqq","tsohu","qzone","renren", "weixin","mshare"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg .share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
postid
15943

Leave a Reply