การทำ Marketing Automation แบบ Open-source ไม่ได้หมายความว่าคุณต้องยกข้อมูลของคุณให้กับผู้ให้บริการ SaaS เสมอไป Mautic ช่วยให้คุณจัดการแคมเปญอีเมล, การติดตามผู้ติดต่อ (contact tracking) และการฟูมฟักลีด (lead nurturing) ได้ภายใต้การดูแลของคุณเอง การรันบน Ubuntu 24.04 อาจต้องใช้ความพยายามมากกว่าการล็อกอินเข้า HubSpot แต่ผลตอบแทนที่ได้คือการควบคุม Stack, ต้นทุน และข้อมูลลูกค้าของคุณได้อย่างสมบูรณ์ คุณเป็นคนตัดสินใจเองว่าจะอัปเดตเมื่อไหร่ จะขยายระบบอย่างไร และข้อมูลของคุณจะถูกเก็บไว้ที่ไหน

ก่อนที่คุณจะเริ่ม ให้ชี้โดเมนมาที่เซิร์ฟเวอร์ของคุณ และตรวจสอบให้แน่ใจว่า Ubuntu 24.04 ของคุณมี RAM อย่างน้อย 2 GB เนื่องจาก Mautic ไม่ใช่ซอฟต์แวร์ที่กินทรัพยากรน้อย เพราะ PHP จะใช้หน่วยความจำเมื่อมีการสร้างเซกเมนต์ขนาดใหญ่ใหม่หรือประมวลผลตรรกะของแคมเปญ หากคุณวางแผนที่จะส่งอีเมลไปยังผู้ติดต่อจำนวนหลายพันราย การมี RAM 4 GB จะช่วยให้การทำงานราบรื่นกว่ามาก

สร้างรากฐานด้วย LEMP Stack

Mautic ต้องการ LEMP stack: Nginx, MySQL และ PHP บน Ubuntu 24.04 เวอร์ชัน PHP เริ่มต้นคือ 8.3 ซึ่งทำงานได้ดีกับ Mautic เวอร์ชันปัจจุบัน เริ่มต้นด้วยการอัปเดตรายการแพ็กเกจของคุณ จากนั้นติดตั้ง Nginx และ MySQL Server หลังจากนั้นให้ติดตั้ง PHP-FPM และส่วนขยาย (extensions) ที่จำเป็นสำหรับ Mautic ดังนี้:

  • php-fpm
  • php-mysql
  • php-imap
  • php-curl
  • php-gd
  • php-xml
  • php-mbstring
  • php-zip
  • php-intl
  • php-bcmath

ส่วนขยายแต่ละตัวมีหน้าที่สำคัญ IMAP ใช้สำหรับอ่านข้อความตีกลับ (bounce messages) และการตอบกลับเพื่อยกเลิกการรับข่าวสาร (unsubscribe) ส่วน GD จัดการเรื่องการประมวลผลรูปภาพสำหรับภาพตัวอย่าง (thumbnails) Mbstring และ Intl จัดการชุดตัวอักษรและการแปลภาษาต่างๆ และ BCMath ช่วยให้คุณคำนวณตัวเลขได้อย่างแม่นยำสำหรับการให้คะแนนลีด (lead scoring) และการคำนวณสกุลเงิน อย่าข้ามส่วนขยายใดๆ ไป มิฉะนั้นตัวติดตั้งจะแจ้งข้อผิดพลาดระหว่างการทำงาน

หากมีการติดตั้ง Apache ไว้แล้ว ให้ลบออกเสียก่อน เนื่องจากเว็บเซิร์ฟเวอร์ทั้งสองต้องการใช้พอร์ต 80 และ 443 การรันทั้งคู่ควบคู่กันจะทำให้เกิดความล้มเหลวแบบเงียบๆ (silent failures) ซึ่งยากต่อการตรวจสอบหาสาเหตุ การใช้คำสั่ง apt remove apache2 ตามด้วย apt autoremove จะช่วยป้องกันปัญหานี้ได้อย่างสิ้นเชิง

ปรับแต่ง PHP และฐานข้อมูล

ตัวติดตั้งและงานเบื้องหลัง (background jobs) ของ Mautic ใช้หน่วยความจำค่อนข้างสูง ให้เปิดไฟล์กำหนดค่า PHP-FPM ที่ /etc/php/8.3/fpm/php.ini และเพิ่มขีดจำกัดหน่วยความจำ (memory limit) เป็น 512 MB ตั้งค่าขนาดการอัปโหลดเป็น 50 MB เพื่อให้คุณสามารถนำเข้ารายชื่อผู้ติดต่อและชุดทรัพยากร (asset bundles) ได้โดยไม่ติดขัด หลังจากบันทึกแล้ว ให้รีสตาร์ท PHP-FPM เพื่อใช้การเปลี่ยนแปลง และในขณะเดียวกัน ให้เพิ่มค่า post_max_size ให้สอดคล้องกับขีดจำกัดการอัปโหลดของคุณ มิฉะนั้น PHP จะปฏิเสธการส่งฟอร์มแบบ multipart ขนาดใหญ่ แม้ว่าค่า upload_max_filesize จะดูถูกต้องแล้วก็ตาม

ต่อไป ให้สร้างฐานข้อมูล MySQL และผู้ใช้เฉพาะสำหรับ Mautic คุณจะตั้งชื่อฐานข้อมูลว่าอะไรก็ได้ แต่ควรเก็บชื่อผู้ใช้และรหัสผ่านไว้ในโปรแกรมจัดการรหัสผ่าน (password manager) เนื่องจาก Mautic จะจัดเก็บทุกการกระทำของผู้ติดต่อ, การตัดสินใจของแคมเปญ และเหตุการณ์การเปิดอีเมลไว้ในตารางเหล่านี้ ดังนั้นการมอบสิทธิ์ที่จำกัดเฉพาะงาน (single-purpose account) จะช่วยลดความเสี่ยงหากมีสิ่งอื่นบนเซิร์ฟเวอร์ถูกบุกรุก

ติดตั้ง Mautic และเครื่องมือต่างๆ

ดาวน์โหลด Mautic เวอร์ชันเสถียรล่าสุดและแตกไฟล์ไปยัง /var/www/html/mautic ตั้งค่าเจ้าของไดเรกทอรีเป็น www-data เพื่อให้เว็บเซิร์ฟเวอร์สามารถเขียนไฟล์แคช (cache files), ล็อก (logs) และอัปเดตการกำหนดค่าในเครื่องได้ สำหรับ Ubuntu นั่นหมายถึงการรันคำสั่ง chown -R www-data:www-data /var/www/html/mautic

คุณยังจำเป็นต้องติดตั้ง Composer และ npm บนเซิร์ฟเวอร์ด้วย Composer ใช้สำหรับจัดการ PHP dependencies และแม้ว่าคุณจะติดตั้งจากไฟล์อัปโหลดที่เตรียมไว้แล้ว แต่คุณจะยังต้องใช้ Composer ในภายหลังเมื่อต้องการเพิ่มปลั๊กอินจาก Marketplace หรือรันการอัปเดตด้วยตนเอง ส่วน npm จะมีความสำคัญหากคุณต้องการปรับแต่งธีมหรือสร้าง frontend assets จากซอร์สโค้ด การเตรียมเครื่องมือทั้งสองอย่างให้พร้อมตั้งแต่ตอนนี้จะช่วยให้คุณไม่ต้องวุ่นวายเมื่อโปรเจกต์มีการพัฒนาต่อไป

กำหนดค่า Nginx และการรักษาความปลอดภัย

Virtual host ของ Nginx ควรชี้ root directory ไปที่ /var/www/html/mautic และกำหนดให้ index.php เป็นดัชนีเริ่มต้น ส่งต่อคำขอ PHP ไปยัง Unix socket ที่ PHP-FPM เปิดไว้ ซึ่งโดยปกติจะอยู่ที่ /run/php/php8.3-fpm.sock การตั้งค่า server block ที่ดีควรมีคำสั่ง try_files เพื่อส่งต่อไปยัง front controller และมี location block เพื่อปฏิเสธการเข้าถึงไฟล์ที่ซ่อนอยู่ (hidden files) ที่ขึ้นต้นด้วยจุด Mautic มาพร้อมกับไฟล์ .htaccess สำหรับ Apache แต่ Nginx จะเพิกเฉยต่อไฟล์เหล่านี้ ดังนั้นการกำหนดกฎการปฏิเสธ (deny rules) อย่างชัดเจนใน virtual host ของคุณจะช่วยรักษาความเป็นส่วนตัวของไดเรกทอรีล็อกและไดเรกทอรีชั่วคราวได้

ก่อนที่จะรันตัวติดตั้งผ่านเว็บ ให้ขอใบรับรอง TLS เสียก่อน โดยใช้ Certbot ร่วมกับ Nginx plugin เพื่อดึงใบรับรองฟรีจาก Let's Encrypt และเปลี่ยนเส้นทางทราฟฟิกจาก HTTP เป็น HTTPS โดยอัตโนมัติ เนื่องจาก Mautic จัดการข้อมูลการเข้าสู่ระบบและข้อมูลผู้ติดต่อ จึงไม่มีเหตุผลใดที่จะปล่อยให้ข้อมูลเหล่านี้ถูกส่งผ่านข้อความธรรมดา (plain text)

Cron Jobs คือกลไกขับเคลื่อนหลัก

This step is non-negotiable. Without scheduled tasks, Mautic is a dashboard that does nothing. The application queues campaign actions, email sends, and segment recalculations in the database, then relies on the command line to process them.

Set up cron jobs for the Mautic user to handle these background duties:

  • Updating segments
  • Running campaigns
  • Sending emails
  • Fetching bounces

In practice, that means invoking Mautic’s console commands at different intervals. Segment rebuilds can run hourly. Campaign triggers and email queue processing usually need a tighter window, every five to fifteen minutes depending on volume. Bounce fetching via IMAP should run regularly enough that your sender reputation does not suffer from unchecked spam complaints. Watch your syslog or the cron output to confirm they finish without memory errors.

Using the Platform

Once the installer completes and cron is humming, log into the dashboard. The interface centers on three building blocks: contacts, segments, and campaigns.

Use the drag-and-drop campaign builder to design email workflows. A new subscriber enters the flow, waits a day, receives a welcome message, and branches based on whether they clicked a link. Meanwhile, the Points system quietly scores leads when they visit pricing pages or open product announcements. You decide the thresholds that signal a hot lead worth a sales call.

Segments group contacts automatically by rules you define. You might segment everyone who opened a campaign in the last thirty days, or isolate contacts in a specific country. Forms living on your landing pages feed directly into these segments. Link the pieces together and you have an automated nurture sequence that reacts to behavior instead of blasting the same message to your entire list.

The Real Work After Deploy

Standing up Mautic on Ubuntu 24.04 is only the beginning. Back up your database and your /var/www/html/mautic directory before every update. Watch PHP error logs when you install new plugins. Test cron output after you scale your contact list upward, because a job that finishes in seconds at one thousand contacts may time out at fifty thousand.

Self-hosting trades the convenience of a managed SaaS for sovereignty over your marketing data. There is no vendor lock-in, no per-contact pricing surprises, and no third-party holding your analytics hostage. You own the server, the database, and the relationship with your audience. For teams willing to maintain a Linux box and a handful of cron expressions, that trade is usually worth it.