⚠️ Khởi động LiteSpeed thất bại do lỗi cú pháp systemd (dòng 9) — xử nhanh ngay! 🌿🤔 - Shopee Khuyến mãi - Review sản phẩm và mua sắm
Bài đăng

⚠️ Khởi động LiteSpeed thất bại do lỗi cú pháp systemd (dòng 9) — xử nhanh ngay! 🌿🤔


⚠️ Khởi động LiteSpeed thất bại do lỗi cú pháp systemd (dòng 9) — xử nhanh ngay! 🌿🤔

1) Chẩn đoán tức thì 😲

Chính systemd báo lỗi "parse error" ở dòng 9 file unit, nên service không thể load lại.
Chạy chuỗi lệnh sau để nhìn rõ lỗi và log chi tiết:

# 1. Xem log chi tiết  journalctl -xeu lshttpd.service --no-pager -n 200    # 2. In file unit kèm số dòng để soi dòng 9  nl -ba /usr/lib/systemd/system/lshttpd.service | sed -n '1,40p'  sed -n '9p' /usr/lib/systemd/system/lshttpd.service    # 3. Kiểm tra cú pháp unit bằng systemd-analyze  systemd-analyze verify /usr/lib/systemd/system/lshttpd.service  

Nếu dòng 9 bắt đầu bằng chữ "P…", khả năng cao là một directive viết sai (ví dụ "PIDFile" gõ sai, thừa ký tự, hoặc dính ký tự lạ/CRLF).

2) Mẫu file unit "chuẩn" cho LiteSpeed Enterprise 💡

Đối chiếu và sửa file của bạn theo mẫu chuẩn dưới đây. Chỉ cần đảm bảo đường dẫn lswsctrl và PID khớp với máy bạn (mặc định của LiteSpeed Enterprise là như dưới):

# /usr/lib/systemd/system/lshttpd.service  [Unit]  Description=LiteSpeed HTTP Server  After=network.target remote-fs.target nss-lookup.target  Wants=network-online.target    [Service]  Type=forking  PIDFile=/usr/local/lsws/logs/lshttpd.pid  ExecStart=/usr/local/lsws/bin/lswsctrl start  ExecStop=/usr/local/lsws/bin/lswsctrl stop  ExecReload=/usr/local/lsws/bin/lswsctrl reload  KillMode=process  LimitNOFILE=1048576  TimeoutStartSec=120  TimeoutStopSec=60  PrivateTmp=true  Restart=on-abnormal    [Install]  WantedBy=multi-user.target  

3) Sửa nhanh, có backup, chống CRLF 👉🍀

Dưới đây là script an toàn: sao lưu file hiện tại, ghi lại nội dung mẫu, khử CRLF nếu có, rồi reload/restart.

set -euo pipefail    # Sao lưu file unit cũ  cp -a /usr/lib/systemd/system/lshttpd.service{,.bak.$(date +%F-%H%M%S)}    # Ghi lại file unit "chuẩn"  cat >/usr/lib/systemd/system/lshttpd.service <<'UNIT'  [Unit]  Description=LiteSpeed HTTP Server  After=network.target remote-fs.target nss-lookup.target  Wants=network-online.target    [Service]  Type=forking  PIDFile=/usr/local/lsws/logs/lshttpd.pid  ExecStart=/usr/local/lsws/bin/lswsctrl start  ExecStop=/usr/local/lsws/bin/lswsctrl stop  ExecReload=/usr/local/lsws/bin/lswsctrl reload  KillMode=process  LimitNOFILE=1048576  TimeoutStartSec=120  TimeoutStopSec=60  PrivateTmp=true  Restart=on-abnormal    [Install]  WantedBy=multi-user.target  UNIT    # Khử CRLF nếu lỡ copy từ Windows  tr -d '\r' </usr/lib/systemd/system/lshttpd.service > /tmp/lshttpd.service && \  mv /tmp/lshttpd.service /usr/lib/systemd/system/lshttpd.service    # Kiểm tra cú pháp  systemd-analyze verify /usr/lib/systemd/system/lshttpd.service    # Nạp lại unit và khởi động  systemctl daemon-reload  systemctl enable lshttpd --now  systemctl status lshttpd -l --no-pager    # Kiểm tra PID tồn tại khớp PIDFile  cat /usr/local/lsws/logs/lshttpd.pid || true  

4) Nếu vẫn lỗi, kiểm tra thêm 🤔

  1. Quyền/SELinux trên thư mục lsws:

chown -R lsadm:lsadm /usr/local/lsws 2>/dev/null || true  restorecon -Rv /usr/local/lsws || true  
  1. Có đổi vị trí PID hay nhầm tên file PID không?

grep -R "PIDFile" /usr/lib/systemd/system/lshttpd.service  ls -l /usr/local/lsws/logs | grep pid  
  1. Thử điều khiển trực tiếp bằng script gốc:

/usr/local/lsws/bin/lswsctrl stop  /usr/local/lsws/bin/lswsctrl start  
  1. Kiểm tra file cấu hình LiteSpeed hỏng:

# Xem lỗi trong logs nếu start không lên  tail -n 200 /usr/local/lsws/logs/error.log  
  1. Khôi phục file unit từ gói cài (nếu bạn cài từ RPM của LiteSpeed):

rpm -qf /usr/lib/systemd/system/lshttpd.service  # nếu cần, reinstall package để lấy lại unit nguyên bản  # rpm -Uvh --replacepkgs /đường/dẫn/gói-litespeed.rpm  

5) Lưu ý quan trọng 💖

  • lsws.service thường chỉ là alias/redirect đến lshttpd.service. Sửa đúng file /usr/lib/systemd/system/lshttpd.service.

  • Mọi directive trong phần [Service] phải đúng chính tả (viết hoa/lowercase đúng chuẩn systemd), không có ký tự lạkhông thừa dấu :.

  • Sau mỗi lần sửa unit: systemctl daemon-reload trước khi restart.

6) Cần mình viết script "tự vá" tự phát hiện lỗi dòng 9?

Mình có thể cung cấp một script bash tự đọc dòng 9, so sánh với whitelist directive (PIDFile|ExecStart|ExecStop|...), nếu sai sẽ tự thay bằng bản chuẩn rồi restart. Bạn muốn mình xuất luôn không? 💖👉🍀

— nhận thiết kế website, vận hành website, máy chủ, sửa lỗi, diệt virus và mã độc cho server liên hệ 0906849968

#Hashtag: #LiteSpeed #Systemd #ServerAdmin #DevOps #WHM #cPanel #LinuxOps #TroubleshootingVui lòng liên hệ Queen Mobile 0906849968 để được hướng dẫn chi tiết

Đăng nhận xét

Developed by Jago Desain