วิธีทำให้ WordPress ปลอดภัย

Secure WordPress

ระดับ Server (ความปลอดภัยพื้นฐาน)

  • ใช้ PHP เวอร์ชันล่าสุดที่รองรับ WordPress เช่น PHP 8.3
  • เปิด HTTP Strict Transport Security (HSTS) บังคับใช้ HTTPS
  • ใช้ Cloudflare (ฟรี) หรือบริการ WAF (เช่น Sucuri, Patchstack) เพื่อบล็อก bot / DDoS
  • ต้องมีระบบสำรองข้อมูลรายวัน

ระดับ WordPress Core

อัปเดต

  • เปิด Auto-update สำหรับ core/plugin/theme

หรือ ใส่ใน functions แบบบังคับไว้เลย

add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );

ปรับปรุง wp-config.php

  • ปิดการแก้ไขผ่าน admin เผื่อ admin คนไหนเผลอไปกด และบังเอิญไปแก้ไขโดยไม่ตั้งใจ
define( 'DISALLOW_FILE_EDIT', true );

ปิด XML-RPC

ซึ่งมีความเสี่ยงถูกใช้เป็นช่องทาง brute-force attack

add_filter( 'xmlrpc_enabled', '__return_false' );

หรือ Block ที่ Web Server ที่ไฟล์ .htaccess

<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
</Files>

Plugin แนะนำ

Plugin เสริมความปลอดภัยระดับสูง

  • Wordfence / iThemes Security / Patchstack หน้าที่ Firewall + Malware Scan
  • Limit Login Attempts: จำกัดความพยายามเข้าสู่ระบบผิดพลาด
  • 2FA (Two-Factor Authentication): ใช้ปลั๊กอินเช่น WP 2FA หรือ miniOrange

User Security

  • ปิด user “admin” และตั้งชื่อผู้ใช้ใหม่ให้เดายาก
  • เปลี่ยน URL login เช่น /custom-login โดยใช้ plugin เช่น WPS Hide Login
  • ใช้รหัสผ่านยาก + เปิด 2FA
  • แยกระดับสิทธิ์ให้ชัดเจนในทุก role เช่น ไม่ให้ Editor มีสิทธิ์แก้ Theme/Plugin

การสำรองข้อมูลและการตรวจสอบ

อื่น ๆ ที่สำคัญ

หากต้องการให้แนะนำ หรือกำลังหาผู้ช่วยตั้งค่าความปลอดภัย ติดต่อ torr.dev ได้ครับ