UBUNTU
*****------------------*********
สำหรับผมได้ทดลองทำตามแล้ว และได้ค่า config ไฟล์ดังนี้ซึ่งทำงานได้
แต่อย่าลืมว่า หากเรากำหนดไอพีของ network card อะไรก็ต้องมีค่านั้นด้วยเช่น ค่า config file ของผมที่ได้ผมมี Ip เครื่อง 192.168.254.1
ddns-update-style interim;
#ad-hoc;
ignore client-updates;
# v102
subnet 192.168.254.0 netmask 255.255.255.0 {
default-lease-time 21600;
max-lease-time 43200;
#server-name "43200";
#max-lease-time 21600;
# option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
# option domain-name-servers 192.168.1.1 , 203.155.33.1;
option time-offset -18000;
range dynamic-bootp 192.168.254.128 192.168.254.252;
# notebookpd
host nsnotebook {
hardware ethernet 00:0d:60:7b:f2:b9;
fixed-address 192.168.254.5;
}
}
# v101
subnet 192.168.50.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option time-offset -18000;
range dynamic-bootp 192.168.50.128 192.168.50.254;
}
# 103
subnet 192.168.103.0 netmask 255.255.255.0 {
option routers 192.168.103.254;
range dynamic-bootp 192.168.103.101 192.168.103.200;
}
#v104
subnet 192.168.104.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option time-offset -18000;
range dynamic-bootp 192.168.104.128 192.168.104.254;
}
# 101
subnet 192.168.101.0 netmask 255.255.255.0 {
option routers 192.168.101.254;
range dynamic-bootp 192.168.101.101 192.168.101.200;
}
ค่าที่ได้ของผมจะมีการกำหนด การจ่าย ip หลายกลุ่ม ซึ่งผมใช้ร่วมกับการ config router กำหนดเป็น vlan โดยแต่ละ VLAN จะมีกลุ่ม IP ที่ต่างกันออกไปครับ
edit @ 2007/04/23 23:01:48
edit @ 2007/05/10 19:14:01
edit @ 2007/05/23 11:46:11
วันนี้ผมมีทางให้เลือก 2 วิธี คือใช้ UserDir กับ การสร้าง Virtual Host
Listen 9001
NameVirtualHost *:9001
<VirtualHost *:9001>
ServerAdmin webmaster@localhost
DocumentRoot /home/tee/VHosts/mydomain.com
<Directory /home/tee/VHosts/mydomain.com>
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride All
#Order allow,deny
#allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>
#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#<Directory "/usr/lib/cgi-bin">
# AllowOverride None
# Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Order allow,deny
# Allow from all
#</Directory>
#ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
#CustomLog /var/log/apache2/access.log combined
ServerSignature On
#Alias /doc/ "/usr/share/doc/"
#<Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#</Directory>
</VirtualHost>
อธิบายส่วนสำคัญๆ ไดัดังนี้
1.1 Listen 9001 - ให้เปิด port นี้เอาไว้ (จริงๆ สำหรับ Ubuntu
ส่วนนี้ default เค้าจะเอาไว้ใน /etc/apache2/ports.conf
แต่เอาไว้ตรงนี้ก็ได้ ไม่ผิดแต่อย่างใด)
1.2 DocumentRoot /home/tee/VHosts/mydomain.com - ก็กำหนด ที่อยู่ของ file เว็บไซต์เลย อย่าลืมสร้างด้วยล่ะ
1.3
<Directory /home/tee/VHosts/mydomain.com>....</Directory> -
ภายใต้ tag นี้ก็เพื่อจะกำหนด option ต่างๆ ของ folder
อันนี้ต้องไปศึกษาเพิ่มเติมครับว่าอะไรทำไรบ้าง ขืนเขียนหมด
จะยาวไม่จบเสร็จแล้วก็ reboot apache $sudo /etc/init.d/apache2 restart
วิธิการเรียกใช้งานมาดูก็ http://localhost:9001/ ครับ
ส่วนที่ผม
comment จาก default ก็คือผมไม่ต้องการจะใช้มันเช่น /cgi-bin/ /doc/
แล้วก็พวก error log เพราะมันจะทำเอา harddisk เต็มแบบไม่รู้ตัวนะครับ
เผลอๆ ทำ apache เดี้ยงไปเลย
จบครับ Virtual Host ง่ายโคด (เว็บนี้ censor ป่าว) เมื่อย เอ้ายังมีอีกเรื่อง
2. การสร้าง UserDir สำหรับผู้ที่มี User บนระบบ เข้าไปแก้ไข /etc/apache2/apache2.conf หาบรรทัดนี้ครับ
# UserDir is now a module
UserDir Htdocs
<Directory /home/*/Htdocs>
AllowOverride FileInfo AuthConfig Limit
Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>
อธิบายส่วนสำคัญๆ ไดัดังนี้
2.1 UserDir Htdocs - กำหนดชื่อ folder ในที่นี้ผมกำหนดเป็น Htdocs โดย default จะชื่อ public_html จะอะไรก็ได้
2.2 <Directory /home/*/Htdocs>...</Directory> - ก็กำหนด option แหละครับ
เสร็จแล้วสร้าง folder Htdocs ลงไปที่ home ตัวเอง เช่น $mkdir /home/tee/Htdocs
ทีนี้ไม่ว่าเราจะยัดอะไรลงไปใน folder นี้ก็จะปรากฏใน http://localhost/~tee/ ครับ เย่ จบแล้วเมื่อยข้อมือ
** ไม่ว่าจะแก้อะไรใน config ถ้าจะให้ take effect ต้อง reboot apache ทุกครั้งนะครับ
http://ubuntuclub.com/node/47