zoukankan      html  css  js  c++  java
  • PHP开源项目之YOURLS

      YOURLS是一个开源的PHP的程序,可以利用它来构建属于自己的URL缩短服务,YOURLS还可以集成到WordPress博客中使用。 YOURLS 的主要功能: 公开的(Public 任何人都可以用它创建短连接)或者私有的(private,只能你自己使用) 可以随机(顺序的)或者自定义。

    1.下载源码

    git clone https://github.com/YOURLS/YOURLS.git

    2. 修改配置

    cd YOURLS
    
    mv user/config-sample.php user/config.php
    
    修改config.php里面的配置参数,依据自己的环境自行修改
    
    define( 'YOURLS_DB_USER', 'root' );
    define( 'YOURLS_DB_PASS', '123456' );
    define( 'YOURLS_DB_NAME', 'yourls' );
    define( 'YOURLS_DB_HOST', 'localhost' );
    define( 'YOURLS_DB_PREFIX', 'yourls_' );
    //上面是数据信息不用多说
    define( 'YOURLS_SITE', 'http://test.com' ); //你自己服务器的域名 用最短的,短地址也是基于这个生成。
    define( 'YOURLS_HOURS_OFFSET', '+8');    //时区偏移 
    define( 'YOURLS_LANG', 'zh_CN' );      //这个语言默认是英文,没有中文包,需要自己去 https://github.com/guox/yourls-zh_CN/下载,放到 user/languages 里面 
    define( 'YOURLS_UNIQUE_URLS', true );   //短地址是否唯一 
    define( 'YOURLS_PRIVATE', true ); //是否私有,如果私有的,则进行api调用生成短地址时需要传递用户名和密码
    define( 'YOURLS_COOKIEKEY', 'A2C7&H~r80pTps{nIfI8VFpTxnfF3c)j@J#{nDUh' );//加密cookie 去 http://yourls.org/cookie 获取
    $yourls_user_passwords = array(
    'admin' => '123456' /* Password encrypted by YOURLS */ , //用户名=>密码 可填多个 登录成功后这里的明文密码会被加密
    );
    define( 'YOURLS_DEBUG', false );      //是否开启调试  
    define( 'YOURLS_URL_CONVERT', 62 );    //使用36进制 还是62进制 这个最好一开始设好不要修改,避免地址冲突,建议62进制
    $yourls_reserved_URL = array(
    'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', //排除一下短地址,这些地址是不会生成的
    );

    3. 添加nginx配置

    server {
    listen 80;
    server_name test.com;
    root /www/YOURLS/;
    index index.php;
    location / {
    try_files $uri $uri/ /yourls-loader.php$is_args$args;
    }
    location ~ .php$ {
    root /www/YOURLS/;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    
    }
    }

    4. 使用方式

    请求地址:http://域名//yourls-api.php
    参数:username(用户名)、password(密码)、format(格式 json)、url(长地址)、action(功能,shorturl)

    正常返回值:

  • 相关阅读:
    第二十一章 PHP编译安装(centos7)
    第二十章 nginx常见问题
    第十九章 keepalived高可用
    dijkstra
    求逆序对
    A
    P2014 [CTSC1997]选课
    樱花 混合背包
    1401D
    CF1343D
  • 原文地址:https://www.cnblogs.com/xingxia/p/php_yourls.html
Copyright © 2011-2022 走看看