春有百花秋有月
夏有凉风冬有雪在签发acme证书时报错Challenge error
<!--more-->
your_domain:Challenge error: <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[Mon Dec 18 10:34:38 AM CST 2023] Please add '--debug' or '--log' to check more details.
[Mon Dec 18 10:34:38 AM CST 2023] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
在签发证书前执行:
/root/.acme.sh/acme.sh --set-default -ca --server letsencrypt
再执行:
阅读剩余部分 →MBA调整Launchpad每列每行的数量方法
MacBook调整Launchpad 启动台的每一行、和每一列图标的数量,达到调整Launchpad图标大小的目的。
defaults write com.apple.dock springboard-columns -int 12
defaults write com.apple.dock springboard-rows -int 8
defaults write com.apple.dock ResetLaunchPad -bool TRUE
killall Dock
以上每行的含义:
1、调整每一列显示图标数量,9表示每一列显示9个,数字部分可根据个人喜好进行设置。
2、调整多少行显示图标数量,这里我用的是6,数字部分你也可以改成8或其他
3、重置Launchpad
4、重启Dock
JAVA&PYTHON
下面是Java和Python之间一些常见方面的区别总结成表格:
码块 |
| 变量定义 | 需要显式指定变量类型 | 不需要显式指定变量类型,使用动态类型 |
| 方法函数 | 方法必须定义在类中,使用关键字 public、private 等修饰符 | 函数可以独立定义,不需要包含在类中,使用关键字 def |
| 类 | 所有代码必须在类中,类是Java程序的基本构建块 | 可以有类,也可以没有类,定义类是可选的 |
| 继承 | 支持单继承,类只能继承一个父类 | 支持单继承和多继承,类可以继承多个父类 |
| 异常处理 | 使用 try-catch-finally 块来捕获和处理异常 | 使用 try-except-finally 块来捕获和处理异常 |
| 包管理 | 使用 Maven、Gradle 等工具管理依赖和构建 | 使用 pip 工具管理依赖和构建 |
| 迭代器 | 使用 for-each 循环遍历集合 | 使用 for-in 循环遍历集合 |
| 面向对象 | 面向对象语言,强调类和对象的概念 | 面向对象语言,但也可以以函数式编程方式使用 |
| 并发 | 支持多线程和并发编程 | 提供多种并发编程方式,包括多线程、协程和异步编程等 |
东北vs北京
东北是家,从05年上大学开始至今18载,累计驻留不足两年。北京不是家,却足足占据我这18载年华的大半时光。
或许,这世界上有两个我,一个在文字里,灵魂在东北,白马春衫慢慢行,另一个我,肉体在北京,蝇营狗苟的都市高楼中意难平。
细细想来,留住我肉体的,其实不是北京,是生活。灵魂向往的也不是东北,却也是生活。

v2ray 一键安装脚本
参考:https://github.com/233boy/v2ray
bash <(wget -qO- -o- https://git.io/v2ray.sh)

linux-debian init
sudo su
passwd root
useradd appadmin
passwd appadmin
打开SSH配置文件/etc/ssh/sshd_config,使用root权限进行编辑:
vim /etc/ssh/sshd_config
PermitRootLogin no //允许root登录
PasswordAuthentication yes //设置是否使用口令验证
service sshd reload
**
*
apt install sudo -y
添加你的本地用户到 sudo 组,可以使用 usermod 命令,如下:
usermod -aG sudo linux265
校正日期和时间:
-- 时区列表
timedatectl list-timezones
-- 修改系统时区为亚洲/上海
sudo timedatectl set-timezone Asia/Shanghai
-- 查看
timedatectl
进行系统更新:
sudo apt update
sudo apt upgrade -y
完成后安装常用软件:
阅读剩余部分 →Debian install typecho
tar -zvcf typecho.tar.gz
wget https://github.com/typecho/typecho/releases/download/ci/typecho.zip
2.解压
unzip typecho.zip
tar -zxvf typecho.tar.gz
3.为了防止权限出现问题, 修改全部文件的权限
chmod 777 -R /var/www/typecho
4.安装PHP及扩展
sudo apt-get -y install php8.2-sqlite3 php8.2-fpm p
<!--more-->
hp-mbstring php8.2-gd
5.启动php7.4-fpm, 默认监听9200端口
sudo systemctl start php8.2-fpm
service php8.2-fpm start
6.检查 PHP-FPM 配置:
打开 PHP-FPM 的配置文件,通常位于 /etc/php/8.2/fpm/pool.d/www.conf 中
确保 listen 配置项与 Nginx 的配置匹配。
/run/php/php8.2-fpm.sock
确保 listen.owner 和 listen.group 配置项与 Nginx 运行的用户和用户组匹配。
打开 Nginx 的虚拟主机配置文件,检查 fastcgi_pass 配置项。
fastcgi_pass unix:/var/run/php-fpm/www.sock;
确保此路径与 PHP-FPM 配置中的 listen 配置项一致。
阅读剩余部分 →Debian install acme
curl https://get.acme.sh | sh
2.生成证书:
/root/.acme.sh/acme.sh --issue --standalone -d passwd.313390.xyz
yum install socat
/root/.acme.sh/acme.sh --issue --standalone -d passwd.313390.xyz
systemctl stop nginx
/root/.acme.sh/acme.sh --issue --standalone -d passwd.313390.xyz
/root/.acme.sh/acme.sh --register-account -m bj.guozhong@gmail.com
/root/.acme.sh/acme.sh --issue --standalone -d passwd.313390.xyz --force
3.以下说明证书生成成功:
[Thu Jun 1 15:23:17 CST 2023] Your cert is in: /root/.acme.sh/passwd.20081014.xyz_ecc/passwd.20081014.xyz.cer
[Thu Jun 1 15:23:17 CST 2023] Your cert key is in: /root/.acme.sh/passwd.20081014.xyz_ecc/passwd.20081014.xyz.key
[Thu Jun 1 15:23:17 CST 2023] The intermediate CA cert is in: /root/.acme.sh/passwd.20081014.xyz_ecc/ca.cer
[Thu Jun 1 15:23:17 CST 2023] And the full chain certs is there: /root/.acme.sh/passwd.20081014.xyz_ecc/fullchain.cer
[Mon Jun 5 17:06:49 CST 2023] Your cert is in: /root/.acme.sh/www.313390.xyz_ecc/www.313390.xyz.cer
[Mon Jun 5 17:06:49 CST 2023] Your cert key is in: /root/.acme.sh/www.313390.xyz_ecc/www.313390.xyz.key
[Mon Jun 5 17:06:49 CST 2023] The intermediate CA cert is in: /root/.acme.sh/www.313390.xyz_ecc/ca.cer
[Mon Jun 5 17:06:49 CST 2023] And the full chain certs is there: /root/.acme.sh/www.313390.xyz_ecc/fullchain.cer
4.将生成的证书文件配置在nginx中:conf.d/20081014.xyz.conf
[root@ip-172-26-2-136 conf.d]# vi 20081014.xyz.conf
阅读剩余部分 →Debian Install fail2ban
Error:
Problem: problem with installed package selinux-policy-targeted-3.14.3-80.el8_5.2.noarch
- package fail2ban-server-1.0.2-3.el8.noarch requires (fail2ban-selinux if selinux-policy-targeted), but none of the providers can be installed
- package fail2ban-1.0.2-3.el8.noarch requires fail2ban-server = 1.0.2-3.el8, but none of the providers can be installed
- conflicting requests
- nothing provides selinux-policy >= 3.14.3-108.e
<!--more-->
l8_7.1 needed by fail2ban-selinux-1.0.2-3.el8.noarch
- nothing provides selinux-policy-base >= 3.14.3-108.el8_7.1 needed by fail2ban-selinux-1.0.2-3.el8.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
解决方式:
yum install --allowerasing fail2ban
apt-get install fail2ban
安装成功后增加规则文件:/etc/fail2ban/filter.d/shadowsocks-libev.conf
配置jail.local文件:
[DEFAULT]
backend = systemd
bantime = 36000
findtime = 600
banaction = iptables-multiport
destemail = bj.guozhong@gmail.com
[sshd]
enabled = true
port = 22
filter = sshd
logpath = /var/log/auth.log
maxretry = 5
[shadowsocks-libev]
enabled = true
port = 3381
filter = shadowsocks-libev
logpath = /var/log/auth.log
maxretry = 3
bantime = 36000
findtime = 3600
systemctl start fail2ban
systemctl status fail2ban
systemctl enable fail2ban
查看日志和监狱内容
tail -f /var/log/fail2ban.log
fail2ban-client status
查看某个规则下的baned状态:
fail2ban-client status sshd
解除限制:fail2ban-client set sshd unbanip ****
有可能产生的问题:
1.新主机安装fail2ban无法启动,提示:
阅读剩余部分 →bitwarden-backup-crontab
crontab -l
crontabl -e
0 0 * * * /opt/bitwarden-backup/bw-data-backup.sh >> /opt/bitwarden-backup/backup.log && find /home/appadmin/bitwarden-backup/ -type f -name "bw-data_backup_*" -mtime +7 -exec rm {} \;
更换到挂载存储之后超过七天的文件没有删除,不知道为什么,换一种方式试试:
0 0 * * * /opt/bitwarden-backup/bw-data-backup.sh >> /opt/bitwarden-backup/backup.log && find /home/appadmin/bitwarden-backup/ -type f -name "bw-data_backup_*" |xargs rm -f
压缩
tar -czvf /path/to/file.tar.gz file
解压
tar -xzvf /path/to/file.tar.gz
加密压缩
tar -czvf - file | openssl des3 -salt -k password -out /path/to/file.tar.gz
for example:
tar -czvf - runshtest | openssl des3 -salt -k password -out ../1.tar.gz
解密解压
openssl des3 -d -k password -salt -in /path/to/file.tar.gz | tar xzf -
for example:
阅读剩余部分 →mount onedrive by Rclone
在Windows电脑上下载Rclone,下载地址:> https://rclone.org/downloads/,然后解压,使用cmd进入解压后的文件夹:
rclone.exe authorize "onedrive"
ps:整个大括号就是token,包括大括号。
直接使用官方提供的一键脚本:
curl https://rclone.org/install.sh | bash
3.配置
安装完成后执行:
rclone config
rclone config
2021/03/03 15:00:17 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> onedrive
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Citrix Sharefile
\ "sharefile"
9 / Compress a remote
\ "compress"
10 / Dropbox
\ "dropbox"
11 / Encrypt/Decrypt a remote
\ "crypt"
12 / Enterprise File Fabric
\ "filefabric"
13 / FTP Connection
\ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
15 / Google Drive
\ "drive"
16 / Google Photos
\ "google photos"
17 / Hadoop distributed file system
\ "hdfs"
18 / Hubic
\ "hubic"
19 / In memory object storage system.
\ "memory"
20 / Jottacloud
\ "jottacloud"
21 / Koofr
\ "koofr"
22 / Local Disk
\ "local"
23 / Mail.ru Cloud
\ "mailru"
24 / Mega
\ "mega"
25 / Microsoft Azure Blob Storage
\ "azureblob"
26 / Microsoft OneDrive
\ "onedrive"
27 / OpenDrive
\ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
29 / Pcloud
\ "pcloud"
30 / Put.io
\ "putio"
31 / QingCloud Object Storage
\ "qingstor"
32 / SSH/SFTP Connection
\ "sftp"
33 / Sugarsync
\ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
35 / Transparently chunk/split large files
\ "chunker"
36 / Union merges the contents of several upstream fs
\ "union"
37 / Webdav
\ "webdav"
38 / Yandex Disk
\ "yandex"
39 / Zoho
\ "zoho"
40 / http Connection
\ "http"
41 / premiumize.me
\ "premiumizeme"
42 / seafile
\ "seafile"
Storage> 26
** See help for onedrive backend at: https://rclone.org/onedrive/ **
OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
Choose a number from below, or type in your own value
1 / Microsoft Cloud Global
\ "global"
2 / Microsoft Cloud for US Government
\ "us"
3 / Microsoft Cloud Germany
\ "de"
4 / Azure and Office 365 operated by 21Vianet in China
\ "cn"
region> 1
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> n
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":qqqqqqqqqq","expiry":"2021-03-03T15:54:34.7442912+08:00"}
token
Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
\ "url"
4 / Search for a Sharepoint site
\ "search"
5 / Type in driveID (advanced)
\ "driveid"
6 / Type in SiteID (advanced)
\ "siteid"
7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
\ "path"
Your choice> 1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!B6yHyawk7kq599Kb4wYXQFe1jafkFoFBqrwS7ZFYLJsUbhule-g-Rax7IpAhk6c8
Chose drive to use:> 0
Found drive 'root' of type 'business', URL: https://imissyou5201314-my.sharepoint.com/personal/codehero_imissyou5201314_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n>y
--------------------
[onedrive]
type = onedrive
region = global
token = {"access_token":"O2bSfUr74YzUssTNQqL2bUzCbxlZMNHa5OEdJwZuOXPfv6IdCdk_E1jWMmjxHNIi7NLZ6GWqaOUARsqq_5JLTDEpo6F5VS5vbTOOVuDP3MhAcvL9aSXBk7BKxXu6yMoZp7uaynmCESg4ADFEFSSefwefwefsefwfgsalkfhsehjfg2bewo_EASPdtlIkjW0v5lCliU1cXxuPGZ_Lq1eOYyjPLMvAJ9pMiKg2-Iw1-844H67E0V9FCY8cBzH3qSui8rgQwt9nBI2PI0uaJ6KlVpQb0IiTQGapw2hgubwprnSVM39B5Z58WUon2ObcJ76CP7VPMvxIFIVnP5oq2gi1PRTxPgN3z64z3Q1hbwM59HqOrwX84uWIvCk63_i6ocVb0nasiY7EaLoF9fJHAnAw2qC3dOng","expiry":"2021-03-03T15:54:34.7442912+08:00"}drive_id = b!B6yHyawk7kq599Kb4wYXQFe1jafkFoFBqrwS7ZFYLJsUbhule-g-Rax7IpAhk6c8
drive_type=business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
onedrive onedrive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
e/n/d/r/c/s/q>
4.安装fuse
apt install fuse3
5.挂载OneDrive
-新建挂载目录
阅读剩余部分 →debian resolv.conf 重启丢失
执行:
apt-get install resolvconf
在/etc/resolvconf/resolv.conf.d/base中增加:
阅读剩余部分 →无线鼠标卡顿
电脑右键-->管理-->设备管理器-->点通用串行总线前面的小>展开-->USB根集线器右键-->属性-->电源管理-->取消选中允许计算机关闭此设备以节约电源
下面还有两个 通用USB**集线器,同样的操作。
tar file add passwd
使用tar对文件压缩加密:
tar -zcvf - pma|openssl des3 -salt -k password | dd of=pma.des3
完成将得到一个pma.des3的打包文件,用你设置的密码替换password。
使用tar对加密文件解压:
dd if=pma.des3 |openssl des3 -d -k password|tar zxf -
注意:命令最后有”-”,它将释放所有的文件。其中-k password可以不使用,这样执行完命令后会提示你输入密码,加上-k参数表示在程序中自动验证密码。
阅读剩余部分 →install chatgpt demo
#更新
sudo apt update
sudo apt upgrade
# 安装依赖
sudo apt install software-properties-common
# 添加 deadsnakes PPA 源
sudo add-apt-repository ppa:deadsnakes/ppa
#安装python
sudo apt install python3
python3 --version
sudo apt install python3-pip
pip3 --version
2.安装python虚拟环境
sudo apt install python3-venv
3.上传chatgpt-web-main.tar.gz,解压并进入到chatgpt-web-main目录
4.创建虚拟环境:
python3 -m venv newchat.env
5.进入虚拟环境
source /opt/chat/chatgpt-web-main/newchat.env/bin/activate
6.配置chatgpt-web-main应用中的openAi key,启动服务:
python3.10 /opt/chat/chatgpt-web-main/main.py
nohup python3.10 /opt/chat/chatgpt-web-main/main.py &
7.配置nginx文件:
server {
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name chat.***.xyz;
ssl_certificate /root/.acme.sh/chat.***.xyz_ecc/chat.***.xyz.cer;
ssl_certificate_key /root/.acme.sh/chat.***.xyz_ecc/chat.***.xyz.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_session_cache builtin:1000 shared:SSL:10m;
proxy_buffering off;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:8184/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
其中proxy_buffering off; 表示打字机效果,不加此行代码无打字机效果,等待输出结果之后一次性返回结果。
阅读剩余部分 →windows bat from linux
1.将以下脚本写入bat文件:执行同步并且本地只保留一周的文件.
start /min cmd /c "C:\Users\user1\AppData\Local\Programs\WinSCP\WinSCP.exe" /console /script=D:\gz\52.69\bak\bitwarden-backup\server_bak.txt
set SrcDir=D:\gz\52.69\bak\bitwarden-backup\bak
set DaysAgo=5
forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c rd /s /q @path"
forfiles /p %SrcDir% /s /m *.* /d -%DaysAgo% /c "cmd /c del /f /q /a @path"
2.定义server_bak.txt文件:
阅读剩余部分 →typecho install and htpasswd config
apt-get update
apt-get install apache2-utils
htpasswd -c /etc/nginx/.htpasswd gz
/etc/nginx/.htpasswd gz
二、安装typecho
https://docs.typecho.org/install
下载php及相关依赖
sudo apt-get install php7.4 php7.4-sqlite php7.4-fpm php-mbstring php7.4-gd安装依赖 sudo apt install php php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml启动php服务:查找对应的 PHP-FPM systemd 服务单元文件。在 /lib/systemd/system/ 目录下查找以 php{version}-fpm.service 命名的文件,例如:
service php7.4-fpm start下载源码(可以在typecho官网找到)
wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip解压源码
unzip typecho.zip对整个源码目录赋予足够的权限
chmod -R 777 /home/typecho配置nginx
server{ listen 80; server_name ****.xyz; root /var/www/typecho; index index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location / { root html; index index.php index.html index.htm; set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; } location /admin { index index.php; try_files $uri $uri/ /admin/index.php?$args; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } # Typecho static files location ~* ^/(usr|admin|themes|plugins)/.*\.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires 24h; add_header Cache-Control public; access_log off; try_files $uri $uri/ /index.php?$args; } }访问:http://****.xyz/install.php 选择sqlite数据库然后下一步...
阅读剩余部分 →
linux crontab
定时任务,自动更新证书和备份文件仅保留一周内的:
[root@iZj6c69digospl6f2d3s45Z bitwarden-backup]# crontab -l
21 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
0 0 * * * /opt/bitwarden-backup/bw-data-backup.sh >> /opt/bitwarden-backup/backup.log && find /home/appadmin/bitwarden-backup/ -type f -name "bw-data_backup_*" -mtime +7 -exec rm {} \;
编辑命令:
crontab -e
使之生效:
阅读剩余部分 →