Guide on Self Hosting Firecrawl on Ubuntu

English 简体中文 繁体中文 ภาษาไทย Tiếng Việt
Summary

Firecrawl is an open-source tool designed to convert web pages into LLM-ready formats like Markdown and HTML. This guide details how to self-host Firecrawl natively on Ubuntu, offering an alternative to Docker for developers seeking more control. The process involves installing Node.js, pnpm, and Redis, then cloning the Firecrawl repository and configuring environment variables. Finally, developers must start Redis, the Firecrawl worker, and the API server in separate terminals, ensuring distinct ports for the worker and API to prevent conflicts. A curl command can then validate the successful setup.

Firecrawl เป็นเครื่องมือโอเพนซอร์สที่ทรงพลังสำหรับการแปลงหน้าเว็บและไซต์ให้เป็นรูปแบบที่สะอาดและพร้อมสำหรับ LLM เช่น Markdown, HTML, ภาพหน้าจอ, ข้อมูลที่มีโครงสร้าง และอื่นๆ แม้ว่า Docker จะถูกใช้โดยทั่วไปเพื่อลดความซับซ้อนในการปรับใช้ แต่คุณอาจต้องการการตั้งค่า Ubuntu แบบเนทีฟมากกว่า เพื่อการควบคุม ความโปร่งใส หรือความสะดวกในการพัฒนาที่ดีกว่า นี่คือวิธีการทำ—.

นอกจากนี้ยังมี คู่มือ เกี่ยวกับวิธีการตั้งค่าในเครื่อง แต่ข้อมูลบางส่วนในคู่มือนั้นล้าสมัยและอาจไม่ทำงานตามที่คาดไว้หากคุณทำตามโดยไม่คิด อย่างไรก็ตาม คุณสามารถใช้เป็นข้อมูลอ้างอิงได้เสมอ

สิ่งที่ต้องมี

ก่อนเริ่มต้น ตรวจสอบให้แน่ใจว่าคุณมี:

  • Node.js (>=18 LTS) ติดตั้งแล้ว
  • pnpm สำหรับการจัดการแพ็กเกจ
  • Redis ทำงานในเครื่อง (localhost:6379) สำหรับคิวงาน

ขั้นตอนการติดตั้ง

1. ติดตั้ง Dependencies

# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential

# Install pnpm globally
curl -fsSL https://get.pnpm.io/install.sh | sh -

# Install Redis
sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis

2. โคลน Firecrawl Repository และ Build

ไปที่ GitHub และโคลน repository ไปยังไดเร็กทอรีในเครื่อง

git clone https://github.com/mendableai/firecrawl.git
cd firecrawl/apps/api

3. กำหนดค่า Environment Variables

คัดลอกตัวอย่างการกำหนดค่าและอัปเดต:

cp .env.example .env
# Edit .env to include:
NUM_WORKERS_PER_QUEUE=8
PORT=3002
HOST=0.0.0.0
REDIS_URL=redis://localhost:6379
REDIS_RATE_LIMIT_URL=redis://localhost:6379

# for local, we can bypass Auth first, otherwise may need Supabase setup
USE_DB_AUTHENTICATION=false

พารามิเตอร์อื่นๆ ในไฟล์สามารถปล่อยไว้ตามเดิมได้ตามต้องการ คุณสามารถเพิ่มตัวแปรสภาพแวดล้อมเสริมได้ตามต้องการ หากคุณต้องการขูดเนื้อหาและบันทึกเป็นภาพหน้าจอ คุณอาจต้องตั้งค่า Playwright และกำหนดค่าที่อยู่บริการใน .env ด้วย หากคุณไม่ได้วางแผนที่จะทำเช่นนั้นในขณะนี้ สามารถปล่อยไว้ตามเดิมได้

4. เริ่มต้น Services

เรียกใช้คำสั่งเหล่านี้ในเทอร์มินัลแยกกัน:

# Terminal A: Start Redis
sudo systemctl start redis-server

# Terminal B: Start the Worker
cd firecrawl/apps/api
PORT=3003 pnpm run workers

# Terminal C: Start the API Server
cd firecrawl/apps/api
pnpm run start

โปรดทราบว่าเมื่อเริ่มต้น workers คุณต้องตั้งค่าพอร์ตอย่างชัดเจนเพื่อไม่ให้รับฟังที่ 3002 ที่ตั้งไว้ใน .env เนื่องจากจะถูกใช้เมื่อเริ่มต้น api server มิฉะนั้นคุณจะเห็นข้อผิดพลาดด้านล่าง

2025-09-04 15:23:23 info [:]: Worker 34522 started 
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use 0.0.0.0:3002
    at Server.setupListenHandle [as _listen2] (node:net:1940:16)
    at listenInCluster (node:net:1997:12)
    at node:net:2206:7
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on WebSocketServer instance at:
    at Server.emit (node:events:519:28)
    at emitErrorNT (node:net:1976:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 3002
}

Node.js v22.19.0

5. ทดสอบการตั้งค่าของคุณ

ใช้ curl เพื่อตรวจสอบว่า API ตอบสนอง:

curl -X POST http://localhost:3002/v2/scrape \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://www.pixelstech.net/document/aboutus.php", "formats":["markdown","html"]}'

คุณควรได้รับเอาต์พุตที่มีโครงสร้าง รวมถึง Markdown และ HTML

นี่แสดงว่าการตั้งค่าใช้งานได้ คุณสามารถสำรวจตัวเลือกเพิ่มเติมที่ Firecrawl มีให้ได้แล้ว

การตั้งค่าที่คล่องตัวนี้ช่วยให้ทุกอย่างโปร่งใสและปรับแต่งได้—เหมาะสำหรับการพัฒนา การมีส่วนร่วม หรือการโฮสต์ด้วยตนเองที่ปรับแต่งอย่างละเอียด ในโพสต์ถัดไป เราจะนำเสนอวิธีการขูดเป็นภาพหน้าจอโดยใช้ Playwright

UBUNTU SETUP GUIDE FIRECRAWL

  RELATED

  COMMENTS

0

No comment for this article.