知了小站 - IT人的小站 - Linux学习 https://www.ydyno.com/category/linux_learn/ Debian 10/11 安装最新版 Nginx https://www.ydyno.com/archives/1740.html 2023-06-05T14:16:00+08:00 Debian 10 安装最新版的Nginx要在Debian 10 上安装最新版的Nginx,可以使用以下步骤1、更新系统sudo apt update sudo apt upgrade2、添加 Nginx 的存储库密钥wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key3、添加 Nginx 的存储库到apt源列表中echo "deb http://nginx.org/packages/mainline/debian/ $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list4、更新存储库并安装 Nginxsudo apt update sudo apt install nginx # 启动 nginx sudo systemctl start nginx # 设置自启 sudo systemctl enable nginxDebian 11 安装最新版的Nginx在Debian 11 上安装最新版的Nginx,可以使用以下步骤1、更新系统sudo apt update sudo apt upgrade # 安装 Nginx 的依赖项 sudo apt install curl gnupg2 ca-certificates lsb-release2、添加 Nginx 的存储库密钥curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg3、添加 Nginx 的存储库到apt源列表中echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list4、更新存储库并安装 Nginxsudo apt update sudo apt install nginx # 启动 nginx sudo systemctl start nginx # 设置自启 sudo systemctl enable nginx debian11 系统增加开机自启脚本 https://www.ydyno.com/archives/1736.html 2023-04-21T10:30:00+08:00 在 debian11 系统增加开机自启脚本时发现 /etc 目录里面没有 rc.local 文件,导致无法添加自启动脚本,这里记录下 debian11 增加开机自启脚本的全过程。修改 rc-local.service 文件cd /lib/systemd/system添加下面内容到 rc-local.service 文件最后[Install] WantedBy=multi-user.target创建 /etc/rc.local 文件创建 /etc/rc.local 文件,并写入下面内容#!/bin/sh -e # 在这里输入需要自启的脚本 exit 0创建完成后需要给其赋予运行权限sudo chmod +x /etc/rc.local启动 rc-local 服务即可sudo systemctl enable rc-local # 启用 sudo systemctl start rc-local.service # 开始运行 sudo systemctl status rc-local.service # 查看状态 Centos 中删除 docker0 虚拟网卡 https://www.ydyno.com/archives/1508.html 2022-04-21T14:32:00+08:00 Centos 删除 Docker 环境后,并不会将虚拟网卡docker0 删除。因此就需要手动处理下ifconfig docker0 down yum -y install bridge-utils brctl delbr docker0这样处理后,才算彻底删除了 Docker 环境。注意:如果你没有删除删除 Docker 环境,那么下次系统启动 Docker Daemon 时还是会自动创建 docker0 网桥。 解决 ssh: connect to host github.com port 22: Connection timed out https://www.ydyno.com/archives/1510.html 2022-04-18T21:50:00+08:00 问题引入当我在国内 Linux 机器上安装好 Git 环境后,将 github 代码克隆到 Linux 服务器出现了如下问题[root@ydyno ~]# git clone git@github.com:elunez/**.git 正克隆到 '**'... ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.解决方法进入 ~/.ssh 查看是否缺少 config 配置文件,如果缺少该配置文件那么使用如下命令创建# 创建并写入文件数据 vi ~/.ssh/config # 写入如下数据,User 填入注册时的邮箱 Host github.com User xxxxx@xx.com Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 443修改文件权限sudo chmod 600 config再次 clone 发现已经没问题了[root@ydyno ~]# git clone git@github.com:elunez/**.git 正克隆到 '**'... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (6/6), done. ^C收对象中: 35% (5/14), 2.67 MiB | 544.00 KiB/s 参考:https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port#enabling-ssh-connections-over-https 记 Debian 11 机器安装 python3 和 pip 的过程 https://www.ydyno.com/archives/1426.html 2022-04-09T16:44:00+08:00 由于搭建 gh-proxy Github加速工具需要用到 python 环境,因此记录下在 Debian10/11 机器安装 python3 和 pip 的过程准备工作apt update开始安装## 安装 python apt install python3.9 apt install python3.9-dev apt install python3.9-venv # 安装 pip wget https://bootstrap.pypa.io/get-pip.py python3.9 get-pip.py # 建立连接 ln -s /usr/bin/python3.9 /usr/local/bin/python3 ln -s /usr/local/bin/pip /usr/local/bin/pip3成品 Github 加速站点:https://proxy.zyun.vip/ Linux 系统中查看 crontab 运行产生的日志 https://www.ydyno.com/archives/1412.html 2022-01-19T16:14:00+08:00 在 Linux 中查看 crontab 运行的日志,只需要编辑系统日志配置文件 rsyslog.conf,取消相关注释即可,命令如下:vi /etc/rsyslog.conf切换英文模式,输入 /cron.* 定位到日志 log 配置将前面的#注释去掉,后面就是是日志文件的路径。保存退出,输入下面命令重启日志服务service rsyslog restart 或者 systemctl restart rsyslog配置完成后,crontab 执行的日志文件就输出到 /var/log/cron.log 了 教你使用开源 Azure 开机面板管理 Azure 账号 https://www.ydyno.com/archives/1404.html 2021-12-27T17:53:00+08:00 提取到 Microsoft Azure 的 API 参数 后我们就可以使用Azure 开机面板管理账号的开机、关机、换IP等操作。使用 Azure 面板方式管理 Azure 账号,能降低 Azure 对账号的风控。该方式适合对 Azure 官网操作不熟的用户,也适合有多个 Azure 账号需要管理的用户。项目地址:https://github.com/elunez/azure-manager安装 Docker应用依赖 Docker 环境,使用一键脚步安装 Dockercurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun && systemctl start docker && systemctl enable docker创建应用使用下面的脚本创建应用docker run -itd --name az \ --restart always \ -p 8888:8888 \ dqjdda/azure-manager:latestARM机器用户请使用docker run -itd --name az \ --restart always \ -p 8888:8888 \ dqjdda/azure-manager:arm初始化管理员账号与密码docker exec -it az flask admin 用户名 密码访问 http://IP:8888 进入管理页面登陆后添加需要管理的账号邮箱:用于多账号区分,可填写你注册azure的邮箱密码:appId|password|tenant|subscriptions创建 VPS添加完账号后,点击账号右侧管理 -> 新增添加后,等待几分钟后刷新页面,就能看到创建好的虚拟机了。虚拟机默认 ssh 端口为 22默认账号与密码:账号:defaultuser 密码:Thisis.yourpassword1重置系统使用下面脚本可以一键重置为纯净的 debian 系统注意替换脚本中的 自定义密码sudo -i curl -fLO https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh && chmod a+rx debi.sh && ./debi.sh --cdn --network-console --ethx --bbr --user root --password 自定义密码 --timezone Asia/Shanghai && shutdown -r now 教你使用 Azure Cli 提取 Azure API 参数信息 https://www.ydyno.com/archives/1394.html 2021-12-07T10:43:00+08:00 Azure 提取开机 API 参数可以用第三方管理工具管理 Azure,下面分享两种提取 Azure Api 的方式。一、通过控制面板的 Cli直接通过 Azure 控制面板的 Cli 去创建 Api 参数将以下命令输入到 Azure cloud shell(使用 Bash)sub_id=$(az account list --query [].id -o tsv) && az ad sp create-for-rbac --role contributor --scopes /subscriptions/$sub_id将会有一些像这样的输出:{ "appId": "***", "displayName": "***", "password": "***", "tenant": "***" }二、通过安装 Azure Cli官网教程:https://docs.microsoft.com/en-us/cli/azure/install-azure-cli不想安装 Azure Cli 的可以看文末最后的另一种方式登陆 Azure Cli使用如下命令登陆Azure:az login输入后 Macos 会自动打开登陆界面,Linux 需要你自己复制登陆地址打开登陆界面。登陆需要管理的账号, 成功后如下图所示创建 Api 访问权限az ad sp create-for-rbac --role contributor --scopes /subscriptions/填入订阅ID输入后就能得到了相关的参数 进入 Docker 容器报错 OCI runtime exec failed: exec failed https://www.ydyno.com/archives/1378.html 2021-10-23T11:03:00+08:00 使用 docker exec -it 容器名/容器ID /bin/bash 进入容器报错报错信息如下:OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown查看相应镜像发现镜像是使用alpine制作的再次输入命令docker exec -it 容器名/容器ID /bin/sh进入成功 Linux 使用脚本一键 DD 脚本(重装)Centos 6/7 系统 https://www.ydyno.com/archives/1374.html 2021-08-04T16:48:00+08:00 Linux一键DD脚本,脚本支持一键 DD(重置)为 CentOS 7、CentOS 6、Debian 9、Debian 10、ubuntu 18.10 等系统,有时候需要手动指定 IP地址、网关地址、子网掩码信息,如果填错就会导致 DD 失败。安装网络工具包# Ubuntu、Debian apt-get install net-tools # CentOS yum install net-tools获取本机IP地址这里获取到的可能是内网地址,也有可能是外网地址,例如:谷歌云机器,获取的就是内网地址输入命令 ifconfig -a 获取获取网关与掩码输入命令 route -nDD成Centos系统输入命令:wget --no-check-certificate -qO AutoDD.sh 'https://raw.githubusercontent.com/hiCasper/Shell/master/AutoReinstall.sh' && bash AutoDD.sh填入获取到的IP,网关、子网掩码信息选择需要重置的系统后,会出现默认密码,复制默认密码保存下来,等待重置结束即可