其他教程

其他教程

Products

当前位置:首页 > 其他教程 >

为你的github图床加速

GG网络技术分享 2025-03-18 16:14 0


大家好,这里是关于[github图床jsdelivr CDN加速搭建教程],[为你的github图床加速]问题的解答,希望对您有所帮助。如果你还想了解更多这方面的信息,请关注本站其他相关内容,共同学习吧!

github图床jsdelivr CDN加速搭建教程

教程大全autoPicCdn,jsdelivr,jsdelivrCDN

github图床jsdelivr CDN加速搭建教程

相关文章:高速github图床,通过jsdelivr CDN全球加速,国内访问极速–autoPicCdn

要求:

1.1个存放PHP文件的空间,并且有一个MySQL数据库。

2.github账户

3.github创建的存储仓库

说明存PHP文件的仅用来调用接口和上传的UI展示等功能。图片存储是存储到你的github存储仓库里的。

搭建步骤:

github账户申请就不说了吧????????创建仓库也不用说了吧??????????

1.在https://github.com/settings/tokens这个地址去申请一个token

勾选:repo:Full control of private repositories 和write:packages

然后就出来了token

2.将文件上传的你的服务器。

然后编辑up.php文件。

error_reporting(0);

header(\'Content-Type: text/html; charset=UTF-8\');

date_default_timezone_set(\"PRC\");

define(\"REPO\",\"testforapi\");//必须是下面用户名下的公开仓库

define(\"USER\",\"yumusb\");//必须是当前GitHub用户名

define(\"MAIL\",\"yumusb@foxmail.com\");//

define(\"TOKEN\",\"YourToken\");//https://github.com/settings/tokens 去这个页面生成一个有写权限的token(repo:Full control of private repositories 和write:packages前打勾)

//数据库配置文件

$database = array(

\'dbname\' => \'pic\',

\'host\' => \'localhost\',

\'port\' => 3306,

\'user\' => \'pic\',

\'pass\' => \'123456\',

);

$table = \'remote_imgs\'; //表名字

define(“REPO","testforapi");//必须是下面用户名下的公开仓库
这个就填写你自己的github账户下面的仓库名字!

define(“USER","yumusb");//必须是当前GitHub用户名
这个填你的github用户名

define(“MAIL","yumusb@foxmail.com");//
这个邮箱,随便填。

define(“TOKEN","b430443b05e6a5a996846c127123cab29de37f88 “);

这个就是上面申请的token。别复制我的,我改了里面内容。

下面是数据库需要填写的内容。改成自己的!!!别复制

$database = array(

\'dbname\' => \'pic\',

\'host\' => \'localhost\',

\'port\' => 3306,

\'user\' => \'pic\',

\'pass\' => \'123456\',

);

'dbname’ => 'pic’,
这个是数据库名,改成自己的。

'host’ => 'localhost’,
这是数据库地址,默认localhost就是本机。这里不用改。

'port’ => 3306,
这是数据库连接端口,默认不用改。

'user’ => 'pic’,
这是数据库用户名,改成自己的。

'pass’ => '123456’,
这是数据库密码,改成自己的。

3.将pic.sql这个数据库导入你的数据库。

然后就可以了,访问你上传文件的地址。

默认是谁都可以上传的。所以你可以把首页文件index.html改个名,或者网站访问加密码限制等等。自己发挥想象力。

为你的github图床加速

前言

把github作为我们免费的图床是很不错的选择,但是国内访问的速度是很慢的,经常会出现无法加载的情况。这里发现一个免费的cdn可以用来加速。

使用方法

我这边是借助Mac+Typora+Picgo来实现的。

下一步是把github的资源采用jsdelivr的cdn来加速。可以看到,支持的还是蛮多的。

github的使用方式如下:

// load any GitHub release, commit, or branch

// note: we recommend using npm for projects that support it

https://cdn.jsdelivr.net/gh/user/repo@version/file

// load jQuery v3.2.1

https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/dist/jquery.min.js

// use a version range instead of a specific version

https://cdn.jsdelivr.net/gh/jquery/jquery@3.2/dist/jquery.min.js

https://cdn.jsdelivr.net/gh/jquery/jquery@3/dist/jquery.min.js

// omit the version completely to get the latest one

// you should NOT use this in production

https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.min.js

// add ".min" to any JS/CSS file to get a minified version

// if one doesn't exist, we'll generate it for you

https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/src/core.min.js

// add / at the end to get a directory listing

https://cdn.jsdelivr.net/gh/jquery/jquery/

所以我们把https://raw.githubusercontent.com/haojunsheng/ImageHost/master/img/20201022135856.png链接进行替换即可。https://cdn.jsdelivr.net/gh//haojunsheng/ImageHost/img/20201022135856.png

我这里写了一个小工具,来方便使用。

path=$1

sed -i "_bak" 's#https://raw.githubusercontent.com/haojunsheng/ImageHost/master#https://cdn.jsdelivr.net/gh/haojunsheng/ImageHost#g' $path

rm $path"_bak"

echo "use jsdelivr as cdn success!"

参考

  1. https://www.jsdelivr.com/

更多

更多内容可以参考我的博客。

标签:

提交需求或反馈

Demand feedback