ขั้นตอนการเปลี่ยน Apache2 Document Root ใน Ubuntu

โดยปกติการติตตั้ง Apache2 web server ใน Ubuntu จะใช้คำสั่ง

sudo apt-get install apache2

Document Root จะถูกตั้งค่าเิริ่มต้นไว้ที่ /var/www  ด้วยเหตุผลประการใดก็แล้วแต่ ถ้าต้องการจะแก้ไข สามารถทำได้ง่าย โดยแก้ file ที่ /etc/apache2/sites-available/default

sudo nano /etc/apache2/sites-available/default

ปกติใน Redhat ผมจะเปิดด้วย vi แต่ใน Ubuntu keyboard shortcut ไม่เหมือนกัน ทำผมสับสน เลยเลี่ยงไปใช้ nano เป็นแทนครับ เนื่องจากใช้ง่ายและสะดวกว่าเพราะว่า keyboard shortcut บอกอยู่ข้างล่าง

ให้เปลี่ยนค่าจาก /var/www เป็น path ที่ต้องการ ซึ่งในนั้นจะมีด้วยกันอยู่ 2 ที่ ต้องเปลี่ยนให้ครบนะครับ จากที่ผมเปลี่ยนผมเปลี่ยน Document Root ไปไว้ที่ /home/www แทน ผมจึงแก้

จาก DocumentRoot /var/www  –> DocumentRoot /home/www

และจาก <Directory /var/www> –> <Directory /home/www>

เมื่อทำการแก้ไขเสร็จให้เซพออกมา และทำการ restart apache ซักที

sudo /etc/init.d/apache2 restart

เท่านี้ก็เรียบร้อยครับสำหรับการแก้ไข Document Root ของ Apache 2  ใน Ubuntu ถ้าใครมีปัญหาหรือสงสัยก็โพสถามกันได้ครับ แล้วยังงัยเดี่ยวจะมาช่วยครับ

บทความที่น่าสนใจ:

Linux
tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>