苹果相关

浏览模式: 标准 | 列表 | 图文
将网站切到1panel 面板下了

将网站切到1panel 面板下了

原来网站是基于 lnmp 的。管理起来也确实没有什么不方便,只是尝试用 1panel 进行管理(本来考虑用 bt 的)。但试试1panel 后感觉还行就尝试全部切到1panel 上看看效果。

当前就已经跑在1panel 上了。运行一段时间看看效果先。为什么这样呢,是尝试先这样用 nginx+runtime打包,后续看是不是打成 image。进行自动化部署。

1panel 本身也有 API,这样就可以自动初始化,自动打包发布了

用1panel 的面板安装了domain-admin

用1panel 的面板安装了domain-admin

在家里的小机器上安装了1panel,并装了一个 domain-admin,用来监控 let's 的SSL 签名。确实因为有时候 let's 不签了。这种情况往往出在泛域名或者多签的时候 。因为偷懒,一台机器上的域名,全部采用了 acme 进行多签,导致同时签 N 个域名时,有一个失败,就会失败了。

用 domain-admin 来监控,因为他可以发通知,什么 Webhook/钉钉/飞书/企业微信之类的都 OK。
家里的机器,用 tailscale 登录。然后手机上启动 tailscale,再打开浏览器,就可以查看和管理域名了。比较方便(没做 APP,暂时不值得,想着未来把类似的功能放到小程序,但想想小程序又要备案。真烦人)
淘宝 NPM 源估计以后还得少用

淘宝 NPM 源估计以后还得少用

在更新 pnpm i 的时候 ,报错,提示 swagger-api 最后的 版本是0.98,但代码里是0.99,所以感到有点郁闷 。到网上查了一下,最新版确实是0.99

于是切换源为:npm config set registry http://mirrors.cloud.tencent.com/npm/,然后再次更新。已经是0.99了。

随便想了想,应该是这个 npm 的镜像更新没有到最新。。还是得少用,或者自己做一个常用的镜像,以防万一啊

Herd的dnsmasq无效的解决。。

Herd的dnsmasq无效的解决。。

Mac下以前用valet,但由于都是命令行(其实也挺方便)。后面又出了Herd,用起来确实比原来舒服多了,至少使用不同版本的PHP时,就没啥大问题。

因为在使用了cf的tunnel试着做了一个穿透。。然后就带了不少妖问题:
1、cf默认过来的时候 就https了。应该是没设置好,然后vite的pnpm dev就不能用了。因为默认是http,然后用 basicSSL进行处理。还要弄本地自签名证书。。。。虽然内外网都可以访问了,但我本地反而卡了。
这点操作,还不如我以前用frpc(或者 zerotier/tailscale )。找一台公网映射过来。。然后开着XX,全局模式的时候 就是公网了。优点是开发的时候全本地,而且还能收到公网发过来的信息。
---
正因为现在这样,结果导致了一个大问题,那就是我在herd tld xx一个新的域名根时。全部无效。。。所以只能重装了。
MAC下因为没有一个完整的重装程序,所以需要参考官方进行几步:删除程序、删除Library/ApplicationSupport,删除/etc/reslover下的文件,清除defaults。
参考:https://herd.laravel.com/docs/1/troubleshooting/uninstalling
How to correct `git` reporting `detected dubious ownership in repository` without adding `safe.directory`

How to correct `git` reporting `detected dubious ownership in repository` without adding `safe.directory`

在部署项目的时候 。先git clone完项目后,再次使用git pull/git fetch的时候 ,就会报这个错误:

```
fatal: detected dubious ownership in repository at '/www/wwwroot/xxxcurrent'
To add an exception for this directory, call:
git config --global --add safe.directory /www/wwwroot/xxx/current
```
如果不想动,直接 偷懒的话,就按上面的提示做就行了。找原因的时候 ,搜到了:https://stackoverflow.com/questions/73485958/how-to-correct-git-reporting-detected-dubious-ownership-in-repository-withou,但好象出问题的都是在wsl2下面。。
但我看下面的评论里有说:可能是因为拉代码的和实际提交的不是同一个人,所以会出现这个情况(https://github.blog/2022-04-18-highlights-from-git-2-36/#stricter-repository-ownership-checks.)官方也有介绍。
之前从来没遇到过,这个倒确实是在于,现在的git项目为了安全,提交的私钥和部署的不一样。所以在这个情况下,就可能会出现这样的问题了。
按提示加好就行了(偷懒的话,就 git config --global --add safe.directory '*' 就完事了)
tailscale fix: NO_PUBKEY 458CA832957F5868

tailscale fix: NO_PUBKEY 458CA832957F5868

在Debian下,按照官方的教程进行gpg和source的添加时,在apt update时会报错 NO_PUBKEY的错误

1、添加GPG
curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
2、UPDATE
sudo apt update
大概率情况下是报:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 458CA832957F5868
Reading package lists... Done
W: GPG error: https://pkgs.tailscale.com/stable/debian bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 458CA832957F5868
--
出现这个问题,大部分是因为用tee生成文件的时候 ,权限不对,所以需要执行一下: chmod o+r /usr/share/keyrings/tailscale-archive-keyring.gpg
再进行sudo apt update,一切正常!
unoconv中文不正常的解决方案

unoconv中文不正常的解决方案

用unoconv将wod转成pdf的时候,中文乱码,这时候解决方案往往是上传中文字体到系统库并注册即可。

中文字体网上下载的地方一堆堆的,就不再赘叙了。
主要就是注册 ,因为用到了mkfontscale之类的命令。但这不是系统自带的,需要安装,因为我用debian。于是:
# 使mkfontscale和mkfontdir命令正常运行
sudo apt-get install ttf-mscorefonts-installer
# 使fc-cache命令正常运行
sudo apt-get install fontconfig
然后在相应的字体目录下运行
mkfontscale
mkfontdir
fc-cache -fv //更新字体缓存
fc-list :lang-zh
然后一切正常
expect: spawn id exp3 not open

expect: spawn id exp3 not open

在尝试使用 envoy 尝试自动部署的时候,遇到了问题,即:如果我要自己创建一个新的域名,那只能上线去执行 lnmp vhost add 的命令。

为什么要使用 lnmp 呢?其实他对我的作用只有一个,多版本的 PHP。因为现在在线上,各种不同版本的 PHP 都在跑,有 PHP5.6 / PHP7.1 / PHP8.1估计后面还会有更多的版本。
于是,我就想着用 expect 来处理

sudo /usr/bin/expect<<EOF
spawn lnmp vhost add
expect {
"Please enter domain" {send "{{$host}}\n";exp_continue}
"Enter more domain name" {send "\n";exp_continue}
"Please enter the directory" {send "\n";exp_continue}
"Allow Rewrite rule" {send "y\n";exp_continue}
"Default rewrite" {send "laravel\n";exp_continue}
"Enable PHP Pathinfo" {send "\n";exp_continue}
"Allow access log" {send "\n";exp_continue}
"Enable IPv6" {send "\n";exp_continue}
"Enter your choice " {send "\n";exp_continue}
"Add SSL Certificate" {send "\n";exp_continue}
"Press any key to start" {send "\r"; exp_continue}
}
expect eof
EOF
但执行后一直报错:
[mpass]: expect: spawn id exp3 not open
[mpass]: while executing
[mpass]: "expect eof"
仔细查了半天,原来最后一句还用了 exp_continue。。expect 认为还没有执行完。所以。就行报错了。
将最后一个 exp_contiue 删除。再次执行,就正常了
@task('lnmp' ,['on'=>'dev'])

@if($force)
sudo rm -rf /usr/local/nginx/conf/vhost/{{$host}}.conf
sudo rm -rf /home/wwwroot/{{$host}}
@endif
sudo /usr/bin/expect<<EOF
spawn lnmp vhost add
expect {
"Please enter domain" {send "{{$host}}\n";exp_continue}
"Enter more domain name" {send "\n";exp_continue}
"Please enter the directory" {send "\n";exp_continue}
"Allow Rewrite rule" {send "y\n";exp_continue}
"Default rewrite" {send "laravel\n";exp_continue}
"Enable PHP Pathinfo" {send "\n";exp_continue}
"Allow access log" {send "\n";exp_continue}
"Enable IPv6" {send "\n";exp_continue}
"Enter your choice " {send "\n";exp_continue}
"Add SSL Certificate" {send "\n";exp_continue}
"Press any key to start" {send "\r";}
}
expect eof
EOF
ls -lah /home/wwwroot/
@endtask
这样就 OK 了
M9折腾记

M9折腾记

买了个 M8s 和 M9,M8s 买的比较早,还是 N6000,于是在上面装了个 sentry,准备替换掉我在轻量服务器上装的这个玩意。但发现有点小浪费,再加上sentry 是直接通过 install.sh 来安装的。很多东西没办法更好的处理,于是先买了台 M9,上了32G 内存,准备用来跑跑虚拟器啥的。考虑在上面再安装一下这个 sentry,将 M8s 和我的轻量解放出来。

先是安装了 ubuntu,有时候 你不得不承认 ubuntu 的兼容性是真的好。所有的驱动都认出来了。为什么这么说呢?因为我后面是想尝试用 omv 来处理,毕竟我还要管理 docker 之类的,用这个会更方便。而且我还特地买了1T 的硬盘。

结果 。。。omv 的安装在第一步就卡住了,网卡认不出。eth 不行,wifi 也不行。。从网上下了驱动。也没认出来。一下子傻眼了,在写的时候 ,我已经在下载 unraid 了。如果它能够跑出来,那我后面就改用 unraid 了。反正 unraid 也不贵。

说白了,就是给这个5-1找点事情做做

如何自动更新 SSL 证书?

如何自动更新 SSL 证书?

听起来好象没问题,因为 acme.sh 就是在做这样的事情,但事实上呢,经常失败。经常有客户跑过来说,怎么网站打不开了?所以找了个检查 SSL 证书的命令,然后放在 console 里跑一下,如果证书在7天内过期就使用 acme.sh 脚本运行一次。

检测的 ssl 命令是:echo -n Q | openssl s_client -servername blog.neatcn.com -connect blog.neatcn.com:443 | openssl x509 -dates -noout,可以看到类似这样的结果 :
depth=2 C = US, O = Internet Security Research Group, CN = ISRG Root X1
verify return:1
depth=1 C = US, O = Let's Encrypt, CN = R3
verify return:1
depth=0 CN = yzhan.com
verify return:1
DONE
notBefore=Mar 25 05:19:28 2023 GMT
notAfter=Jun 23 05:19:27 2023 GMT
简点区分一下数据,notAfter=后的时间就是过期时间,在 laravel 下面就方便了。 Carbon类比较一下(PHP 的 DateTime 类也能比较)。laravel 10开始,new Process()还能多进程。写个简单的脚本,加到 crontab,就完事了。