Polr 短网址及同域名设置
宝塔新建站点
上传至网站根目录解压
网站目录设置为 /www/wwwroot/go.ielts-li.cn/polr/public
配置文件添加/修改
<Directory "/www/wwwroot/go.ielts-li.cn/polr/public"> Require all granted Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
重启 Apache
删除禁用函数 proc_open
只删 proc_open 即可
关闭防跨站攻击 (open_basedir)
重启 php。
SSH
进入网站根目录下载 composer.phar,然后执行安装:
cd /www/wwwroot/go.com/polr
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev -o
Generating optimized autoload files
表示安装成功
cp .env.setup .env
.env 可能需要777 权限
安装使用
打开 https://go.ielts-li.cn/setup
登陆 https://go.ielts-li.cn/login
修改配置
仅能通过 .env
这个文件修改。特别注意:
# Set to true to show an interface to logged off users # If false, set the SETTING_INDEX_REDIRECT # You may login by heading to /login if the public interface is off SETTING_PUBLIC_INTERFACE=true
# You must set SETTING_INDEX_REDIRECT if SETTING_PUBLIC_INTERFACE is false # Polr will redirect logged off users to this URL SETTING_INDEX_REDIRECT=https://ielts-li.cn
# Set to 32 or 62 -- do not touch after initial configuration, 62比32复杂,位数多 POLR_BASE=32
通过CDN获取真实IP
若使用 Cloudflare,请在 vender/autoload.php
的第6行加入:
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; }
同域名反代
ielts-li.cn 配置文件在最后一个 #path <Directory...
前添加反代
#PROXY-START <IfModule mod_proxy.c> ProxyRequests Off ProxyPass /go http://go.ielts-li.cn/ ProxyPassReverse /go http://go.ielts-li.cn/ </IfModule> #PROXY-END
修改服务端 /etc/hosts,添加
127.0.0.1 go.ielts-li.cn
API
https://docs.polrproject.org/en/latest/developer-guide/api/
https://rd.ielts-li.com/api/v2/action/shorten?key=b89da50fe400b610f3b24ff31f14bb&url=http://xxx.yyy&response_type=plain_text
Excel 获取短网址
=WEBSERVICE("https://rd.ielts-li.com/api/v2/action/shorten?key=b89da50fe400b610f3b24ff31f14bb&url=" &$A1& "&response_type=plain_text")
还原原网址
/api/v2/action/lookup
url_ending
: the link ending for the URL to look up. (e.g 5ga)
url_key
(optional): optional URL ending key for lookups against secret URLs
http://example.com/api/v2/action/lookup?key=API_KEY_HERE&url_ending=2
Response:
{ "action": "lookup", "result": "https://google.com" }
错误分析
Warning: require(): open_basedir restriction in effect. File(/www/wwwroot/rd.ielts-li.com/polr/bootstrap/app.php) is not within the allowed path(s): (/www/wwwroot/rd.ielts-li.com/polr/public/:/tmp/:/proc/) in /www/wwwroot/rd.ielts-li.com/polr/public/index.php on line 14
Warning: require(/www/wwwroot/rd.ielts-li.com/polr/bootstrap/app.php): failed to open stream: Operation not permitted in /www/wwwroot/rd.ielts-li.com/polr/public/index.php on line 14
Fatal error: require(): Failed opening required '/www/wwwroot/rd.ielts-li.com/polr/public/../bootstrap/app.php' (include_path='.:/www/server/php/72/lib/php') in /www/wwwroot/rd.ielts-li.com/polr/public/index.php on line 14
打开 open_basedir