第17章 HestiaCP 第17章:故障排查
### 以 root 用户运行 v-command 时提示“命令未找到” 在 `/root/.bashrc` 中添加以下代码:
```bash if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then . /etc/profile.d/hestia.sh fi ```
然后注销并重新登录。完成上述操作后,你就可以运行任意 v-command 了。
### 通过命令行禁用“登录 IP 地址白名单” 自 Hestia v1.4.0 起,我们增加了一些安全功能,包括限制仅允许特定 IP 地址登录。如果你的 IP 地址发生变化,将无法再登录。要禁用此功能,请运行以下命令:
```bash # 禁用该功能 v-change-user-config-value admin LOGIN_USE_IPLIST 'no' # 移除已列出的 IP 地址 v-change-user-config-value admin LOGIN_ALLOW_IPS '' ```
### 能通过 `crontab -e` 更新 cronjobs 吗? 不能。更新 HestiaCP 时,crontab 会被直接覆盖,所做的更改也不会被保存备份。
### 更新 Apache2 后无法重启 Apache2 或 Nginx 错误信息显示:`(98) Address already in use: AG0072: make_sock: could not bind to address 0.0.0.0:80`
软件包更新有时会附带新的配置文件,且旧配置可能已被覆盖……
```bash Configuration file '/etc/apache2/apache2.conf' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. * apache2.conf (Y/I/N/O/D/Z) [default=N] ? ```
看到此提示时,务必按 "N" 或 ENTER 键选择默认值!
如果你误选了 Y 或 I,请从 `/root/hst_backups/xxxxx/conf/apache2/` 目录中替换配置文件(其中 `xxxxxx` 是上次更新 HestiaCP 时创建备份的时间戳),并将 `apache2.conf` 和 `ports.conf` 复制到 `/etc/apache2/` 目录下。
如果没有备份,也可以将 `/usr/local/hestia/install/deb/apache2/apache2.conf` 中的配置复制到 `/etc/apache2.conf`,并清空 `/etc/apache2/ports.conf`。
### 无法绑定地址 在极少数情况下,网络服务的启动速度可能慢于 Apache2 或 Nginx。此时 Nginx 或 Apache2 会拒绝成功启动。
```bash systemctl status nginx ```
这将产生以下错误:
```bash nginx: [emerg] bind to x.x.x.x:80 failed (99: cannot assign requested address) ```
或者在 Apache2 的情况下:
```bash (99)Cannot assign requested address: AH00072: make_sock: could not bind to address x.x.x.x:8443 ```
以下命令应允许服务绑定到不存在的 IP 地址:
```bash sysctl -w net.ipv4.ip_nonlocal_bind=1 ```
### 错误:24: 打开文件过多
```bash
2022/02/21 15:04:38 [emerg] 51772#51772: open() "/var/log/apache2/domains/
此错误表明 Nginx 打开了过多的文件。要解决此问题,请编辑 `/etc/systemd/system/nginx.service.d/override.conf`:
```bash [Service] LimitNOFILE=65536 ```
然后运行:
```bash systemctl daemon-reload ```
在 Nginx 配置文件中添加以下内容(数值需小于或等于 `LimitNOFILE`!):
```bash worker_rlimit_nofile 16384 ```
最后通过 `systemctl restart nginx` 重启 Nginx。
要验证,请运行:
```bash
cat /proc/