Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

WHMCS 安全加固完整指南:從安裝目錄清理到管理後台保護

編輯:Linux 教學

WHMCS 作為主流主機計費系統,安全配置直接關係業務數據安全。本文提供生產環境級加固清單。

1. 刪除安裝目錄

rm -rf /path/to/whmcs/install

2. 設置配置文件權限

chmod 640 /path/to/whmcs/configuration.php
chown nginx:nginx /path/to/whmcs/configuration.php  # 根據 Web 服務器用戶調整

3. 移動敏感目錄至 Web 不可訪問路徑

# 假設 Web 根目錄 /home/user/public_html,WHMCS 安裝於 /home/user/public_html/whmcs
mkdir -p /home/user/whmcs_data
mv /home/user/public_html/whmcs/attachments /home/user/whmcs_data/
mv /home/user/public_html/whmcs/downloads /home/user/whmcs_data/
mv /home/user/public_html/whmcs/templates_c /home/user/whmcs_data/

編輯 configuration.php 更新路徑:

$templates_compiledir = "/home/user/whmcs_data/templates_c/";
$attachments_dir = "/home/user/whmcs_data/attachments/";
$downloads_dir = "/home/user/whmcs_data/downloads/";

4. 重命名管理目錄

mv /home/user/public_html/whmcs/admin /home/user/public_html/whmcs/mysecureadmin123

編輯 configuration.php:

$customadminpath = "mysecureadmin123";

更新 Cron 任務路徑:

php -q /home/user/public_html/whmcs/mysecureadmin123/cron.php

5. 強制 HTTPS 與安全頭

Nginx 配置片段:

server {
    listen 443 ssl http2;
    server_name whmcs.example.com;
    
    # SSL 證書配置...
    
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "strict-origin-when-cross-origin";
    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';";
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # 禁止訪問敏感文件
    location ~* \.(php|inc|sql|bak|log)$ {
        deny all;
    }
}

6. 數據庫安全

  • 使用專用數據庫用戶,僅授予 WHMCS 數據庫權限
  • 禁用數據庫遠程訪問,僅允許 localhost
  • 定期備份並驗證恢復流程

7. 定期更新與監控

  • 啟用 WHMCS 自動更新檢查,及時應用安全補丁
  • 監控 /var/log/whmcs/ 異常登錄嘗試
  • 配置 Fail2Ban 防暴力破解:
[whmcs-auth]
filter = whmcs-auth
action = iptables-multiport[name=whmcs, port="http,https"]
logpath = /var/log/whmcs/access.log
maxretry = 5
bantime = 3600

8. 文件完整性監控(可選)

# 安裝 AIDE
yum install -y aide
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
# 定時任務每日檢查
0 3 * * * /usr/sbin/aide --check | mail -s "AIDE Report" admin@example.com

總結

核心原則:最小權限、目錄隔離、隱藏入口、強制加密、持續監控。按清單逐項落地,可將 WHMCS 攻擊面降至最低。

Copyright © Windows教程網 All Rights Reserved