Bài giảng Tổng quan về Linux - Chương 9: Apache Web Server

48 5 0
Bài giảng Tổng quan về Linux - Chương 9: Apache Web Server

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Apache Web ServerApache Web Server Web server Web server  World Wide Web (www) Là một phát minh nóng World Wide Web (www) Là một phát minh nóng nhất của thế kỷ 20, sau Ti Vi Nó đem đến cho nhất của[.]

Apache Web Server Web server   World Wide Web (www): Là phát minh nóng kỷ 20, sau Ti Vi Nó đem đến cho hàng tỷ người giới giao tiếp thơng qua Internet Người dùng cần đơn giản “click & wait” thơng tin hình thơng qua chương trình web client gọi Browser Ở khía cạnh khác, ta có Web Server, thiết bị phục vụ thơng tin cho hàng ngàn web clients Web server chứa trang Web, scripts, chương trình, multimedia files phục vụ chúng dùng HTTP, giao thức dùng riêng cho việc truyền file đến web browsers Các kỹ thuật Web  Hệ thống địa chỉ, Universal Resource Locators (URLs), cho phép tải loại thông tin khác Internet    HyperText Transfer Protocol (HTTP) định nghĩa ngôn ngữ (protocol) việc làm để web clients servers trao đổi thông tin multimedia HperText Markup Language (HTML) cho phép users biên soạn multimedia hypertext documents TCP/IP protocol phục vụ mức thấp Internet cho phép HTTP ứng dụng khác chạy Call Stack Vai trị Web Server   Web server có vai trò data hiển thị client Ngoại trừ việc dùng XML+ứng dụng Thông thường, web server truyền thông tin browser phải dùng cho thích hợp Web server thực thi chương trình để sinh thơng tin động Ta gọi xử lý serverserverside để sinh trang Web tương tác (Khác với JavaScript, sinh xử lý clientclient-side xử lý tương tác web pages) Web server tạo ứng dụng dùng form Nó cho phép web server đóng vai trị gateway để truy cập vào tài nguyên khác không thuộc Webserver local file systems, database, mainframe data, v.v… Các Web Servers Software  Java Web Server  Apache Web Server  Microsoft Personal Web Server  Microsoft Frontpage Web Server  Microsoft Internet Information Server Web Server Overview  Web Server khơng máy tính lớn nằm phịng server với lực xử lý lớn nhiều memory  Web Server = Computer Hardware + Operating System + Web Server Software + Info Content  Với góc độ software engineer, ta tập trung vào software, đó, Web Server là:  Web Server = Operating System + Web Server Software + Info Content Các thành phần     Operating System: (Windows, UNIX, AS/400, Mainframe) nơi mà web server chạy Web Server Software deamon đợi phục vụ yêu cầu từ web client thông qua mạng Web server phải hiểu request từ clients Protocol dùng Web server Hypertext Transfer Protocol (HTTP) Khái niệm quan trọng TCP port Web Server thường sử dụng port 80, nhiên điều thay đổi tuỳ theo admin cấu hình Nội dung, thơng tin chứa web server Nó thơng tin localhost từ database từ server khác Web Server truyền thống   Web Server truyền thống khơng hiểu nội dung tài liệu Nói cách khác, tất tài liệu xem stream of data từ server đến client Thông thường, web server hyper links nằm documents, links phần document từ nhìn web server Khi user clicks vào hyperlink, browser request document khác từ hyperlink Do đó, browser “quản lý" hyperlink thay web server Ngồi ra, web server khơng biết images, movie hay voice pieces Tất MIME requested riêng lẻ từ browser Document Tree  documents, images, thông tin khác mà web server phải phục vụ tổ chức thành hay dạng cấu trúc phân cấp Gốc điểm bắt đầu với node (hay node) theo sau Chú ý Web tree thường khác với different local file system tree Sample CGI program  #!/usr/bin/perl print "Content"Content-type: text/html\ text/html\n\n"; print " \ \n"; print "CGI Environment\ Environment\n"; print "\ "\n"; print "\ "\n"; print "CGI Environment\ Environment\n"; foreach $env_var (keys %ENV) { print "$env_var = $ENV{$env_var}\\n"; $ENV{$env_var} } print " \ \n"; Dùng SSI SSI Server Side Include  Khi server thực thực thi CGI, một trình biên dịch hay thơng dịch thực chương trình bạn bạn Chương Ch ương trình CGI phải phải sinh vài đáp ứng HTTP và sau tác vụ HTML file server's là sinh đáp ứng truyền trang HTML sinh ngược trở lại client/browser  Khi server trả trả tập tin với SSI commands nó, nó phải đọc dịng tìm cú pháp lệnh đặc trưng SSI Đây gọi parsing a file Lệnh Lệnh SSI có xuất nơi HTML file Ví dụ SSI           This is the Home Virtual Page Welcome to SSI Page

This file was last mondified on >

Kết SSI Cú pháp SSI Mỗi lệnh SSI có có dạng sau: sau: >  config Sets the time, size, or errorerror-message format echo Inserts the values of SSI variables into your Web page exec Executes a system command or a CGI program and inserts the output of that command into a Web page flastmod Inserts into your Web page the date of the last time a file was modified fsize Inserts the size of a file into your Web page Include Inserts the contents of HTML files into your Web page Apache Web Server  Apache HTTPHTTP-server sử dụng rộng rãi giới Nó cịn web server phổ biến cho hệ thống Linux Một web server Apache có chức đơn giản, đồng thời hiển thị yêu cầu HTML từ client yêu cầu Đây dịch vụ vơ mạnh mẽ cho browser client yêu cầu kết nối HTTP Có thể hiểu Apache server hoạt động hình minh hoạ: CẤU HÌNH SỬ DỤNG APACHE SERVER   Việc hiệu chỉnh tập tin cấu hình dịch vụ Apache cung cấp cho nhà quản trị nhiều lựa chọn tùy thuộc vào yêu cầu hệ thống người dùng hệ thống Có hệ thống cần cài đặt Apache cho mục đích phục vụ cho nhu cầu hiển thị thông tin hệ thống cách tĩnh, số hệ thống khác mong muốn cài đặt với mục đích thương mại điện tử + tập tin cấu hình “/etc/httpd/conf/httpd.conf” : tập tin cấu hình quan trọng cho Apache server Nó cho phép nhà quản trị cấu hình nhiều tùy chọn khác nhau, đồng thời cho phép nhà quản trị cấu hình bảo mật hệ thống dịch vụ Khởi động dừng Apache  /etc/init.d/httpd start  /etc/init.d/httpd stop  /etc/init.d/httpd restart Cấu hình Apache  Kiểm tra file /etc/httpd/conf/httpd.conf có khai báo sau:     ServerName pascal.hcmutrans.edu.vn ServerAdmin webmaster@hcmutrans.edu.vn Listen *:80 Port 80  Sau start lên lệnh  /etc/init.d/httpd start Cấu hình User’s Personal Home Pages  Kiểm tra file /etc/httpd/conf/httpd.conf có khai báo sau: Options Indexes MultiViews AllowOverride All Allow from from all Order allow,deny Cấu hình miền Web ảo  Apache cho phép cấu hình nhiều domain server, listen port  Ưu điểm: Tận dụng tài nguyên Server Giảm chi phí quản trị, tăng cường khả webweb-hostting  Ví dụ minh hoạ: Dùng server để cấu hình cho website: • http://www.hcmutrans.edu.vn • http://tainguyen.hcmutrans.edu.vn • http://ity.hcmutrans.edu.vn Các bước cấu hình  Cấu hình DNS server cho miền Host Trong file hcmutrans.edu.vn.zone cần thêm dòng sau: www IN ity IN tainguyen IN  Cấu A A A 172.16.10.1 172.16.10.1 172.16.10.1 hình Apache Web Server ServerName www.hcmutrans.edu.vn        NameVirtualHost 172.16.10.1 ServerName www.hcmutrans.edu.vn ServerAdmin webmaster@hcmutrans.edu.vn ErrorLog logs/hcmutranslogs/hcmutrans-error_log CustomLog logs/hcmutranslogs/hcmutrans-access_log common ServerName tainguyen.hcmutrans.edu.vn   ServerName tainguyen.hcmutrans.edu.vn  ServerAdmin webmaster@hcmutrans.edu.vn  ErrorLog logs/tainguyenlogs/tainguyen-error_log  CustomLog logs/tainguyenlogs/tainguyen-access_log common  ServerName ity.hcmutrans.edu.vn   ServerName ity.hcmutrans.edu.vn  ServerAdmin webmaster@hcmutrans.edu.vn  ErrorLog logs/itylogs/ity-error_log  CustomLog logs/itylogs/ity-access_log common 

Ngày đăng: 29/06/2023, 10:11

Tài liệu cùng người dùng

Tài liệu liên quan