2/02/2554

การติดตั้ง Web Server บน CentOS Linux 5.5

โปรแกรมที่นิยมใช้ทำเครื่องบริการเว็บไซต์บน CentOS ส่วนใหญ่จะใช้โปรแกรม Apache HTTPd Server
ขั้นตอนการติดตั้ง Web Server บน CentOS Linux
1. ตรวจสอบแพ็กเกจเว็บเซิร์ฟเวอร์
# rpm -qa httpd
กรณียังไม่ได้ติดตั้งให้ทำการติดตั้งใหม่ดังนี้
# yum -y install httpd
2. ตรวจสอบพาทไฟล์คอนฟิก httpd.conf
# rpm -ql httpd | less
3. ทำการแก้ไขไฟล์คอนฟิก
# cd /etc/httpd/conf
# ls
# vi httpd.conf
จุดที่แก้ไขและควรรู้จักมีดังนี้
#--------------------------
# Timeout: The number of seconds before receives and sends time out. ช่วงเวลาที่ให้ผู้ใช้เรียกใช้งานเว็บไซต์
#
Timeout 120
#Listen 12.34.56.78:80 หมายเลขพอร์ตของเว็บเซิร์ฟเวอร์
Listen 80
# Load config files from the config directory "/etc/httpd/conf.d". โหลดโมดูลเสริม
#
Include conf.d/*.conf
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. กำหนดอีเมล์ผู้ดูแลระบบ
# ServerAdmin root@localhost เปลี่ยนเป็น
ServerAdmin admin@cmsthailand.com
# DocumentRoot: ห้องเก็บเว็บไซต์หลัก
DocumentRoot "/var/www/html"
# UserDir: ต้องการให้ผู้ใช้ในระบบสร้างเว็บไซต์ได้ไหม
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disable
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
# เปิดให้ผู้ใช้ในระบบมีเว็บไซต์ได้
UserDir public_html
# DirectoryIndex:ไฟล์หลักที่เรียกใช้งาน
DirectoryIndex index.html index.html.var index.php index.cgi index.shtml
# AccessFileName: เปิดใช้การป้องกันการเข้าถึงไดเร็กทอรี
AccessFileName .htaccess
# ScriptAlias: ห้องเก็บสคริปต์ CGI ที่สร้างจากภาษา PERL และ PYTHON
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
# Specify a default charset for all content served; ฟอนต์หลักที่เรียกใช้งาน
AddDefaultCharset UTF-8
AddDefaultCharset tis-620
# To use CGI scripts outside of ScriptAliased directories: เพิ่มนามสกุลไฟล์ CGI
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .pl .py
# To parse .shtml files for server-side includes (SSI):เปิดใช้งาน SSI
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
# --------------------------
4. หลังจากแก้ไขเสร็จแล้วให้ทำการ START Apache
# service httpd start
5. ตั้งให้ Apache ทำงานตอนบู๊ตเครื่อง
# chkconfig httpd on
6. ทดสอบดูผลทางโปรแกรมเว็บบราวเซอร์
http://IP_Address เช่น http://192.168.3.12

7. ทดสอบเขียนภาษา HTML
# cd /var/www/html
# vi index.html

2. ทดสอบเรียกเว็บไซต์ใหม่ทางโปรแกรมเว็บบราวเซอร์
http://IP_Address เช่น http://192.168.3.12

-----
(c) CMSThailand Learning Center
Write by A.Arnut Ruttanatirakul

http://www.arnut.com/b/node/333

0 ความคิดเห็น:

แสดงความคิดเห็น