คลังเก็บป้ายกำกับ: brew

WSL: การติดตั้ง Apache

การติดตั้ง Apache โดยใช้ brew อย่างง่าย ๆ

  1. ติดตั้ง Apache โดยคำสั่ง
    brew install apache2
    หรือ
    brew install httpd
  2. เปิด URL
    http://localhost/
    จะเห็นว่ามันจะ redirect ไปที่
    https://localhost/
    เสมอ
  3. โดย default brew จะสร้าง visual host ไว้ใน /home/linuxbrew/.linuxbrew/etc/httpd/extra/httpd-vhosts.conf แต่รู้สึกว่ามันจะจัดการยากกว่าการติดตั้งแบบ apt-get install httpd “Debian Way” เลยจะสร้างโฟลเดอร์ใหม่โดยใช้คำสั่ง
    cd /home/linuxbrew/.linuxbrew/etc/httpd
    mkdir conf-available conf-enabled mods-available mods-enabled sites-available sites-enabled

    sudo nano /home/linuxbrew/.linuxbrew/etc/httpd/httpd.conf
    และเปิดเพิ่มบรรทัดโดยจะเป็นการ download config ทั้งหมดใน folder conf-enabled, sites-enabled
    # Include generic snippets of statements
    IncludeOptional conf-enabled/*.conf
    
    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf
    
    ServerName 127.0.0.1
    
  4. เพิ่ม Visual Host โดยทำตาม Apache: VirtualHost
  5. ติดตั้ง SSL
  6. เทสโดยใช้คำสั่ง
    apachectl configtest
  7. เริ่มการทำงานใหม่โดย
    brew services start httpd