搭建自己的随机图API

因为一直没有为博客的随机封面找到好的api,所以就在网上搜索如何自己制作,发现很简单,只需要:有图、写个php。 生成图片链接 首先选好自己的目标图片,上传至internet,可以选择自己服务器、云存储空间、GitHub图床等,获取所有图片外链即可,建议图片名字选择纯数字。 PHP生成随机链接 制作图片api的方式有很多,本文参考如下代码,通过php生成随机数字,拼接得到随机访问图片的链接,然后跳转对应链接。 <?php //初始化随机数生成器种子,这行代码也可以删除 $seed = time(); //获取随机数 $num = rand(1,42); //拼接图片地址 $picpath = "http://ritn3ta2k.hn-bkt.clouddn.com/api-img/".$num.".jpg"; //重定位到图片 die(header("Location: $picpath")); ?> 参考资料

2022年10月4日 · 1 分钟 · Vinkey

Mac下Nginx的安装与配置

环境:MacBook Air M1, macOS Monterey 12.6 安装 建议选择homebrew安装,安装完成后会显示基本信息,后续如果要重新查看可通过命令实现。 brew install nginx 安装 brew info nginx 查看信息 Docroot is: /opt/homebrew/var/www The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo. nginx will load all files in /opt/homebrew/etc/nginx/servers/. To restart nginx after an upgrade: brew services restart nginx Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/nginx/bin/nginx -g daemon off; 使用 brew services start nginx 启动 brew services stop nginx 停止 nginx -t 测试配置文件 ...

2022年10月2日 · 2 分钟 · Vinkey

Mac个人使用技巧 随时更

2021年12月31日拥有了我的第一台苹果电脑MacBook Air Apple M1 芯片,之前没有用过Mac系统因此会遇到一些操作上的差异,当然这个过程中也有一些好用的功能,这个文章就记录一些我认为有趣的地方。 快速定位目标文件/文件夹 在访达界面中,使用 Shift-Command-G ,打开“前往文件夹”窗口,输入路径即可 - 在其他软件中选择本地文件时,使用**/**,打开“前往文件夹”窗口,输入路径即可

2022年9月24日 · 1 分钟 · Vinkey