歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 中小企業服務器配置方案 第三章(1)

中小企業服務器配置方案 第三章(1)

日期:2017/2/27 9:48:52   编辑:更多Linux

  第三章 Web服務器

第一節 Apache服務器


1.1 簡介

Apache是世界排名第一的Web服務器,根據著名的Web服務器調查公司Netcraft的調查,世界上百分之五十以上的Web服務器都在使用Apache。

縱觀Apache,它為我們的網絡管理員提供了豐富多彩的功能,包括目錄索引、目錄別名、內容協商、可配置的HTTP錯誤報告、CGI程序的SetUID執行、子進程資源管理、服務器端圖象映射、重寫URL、URL拼寫檢查以及聯機手冊man等。也就是說,如果您在Linux Server上成功安裝配置了Apache之後,您的計算機也將隨著Apache的生效而搖身一變,成為一台名副其實的Web Server,這種變化的確是激動人心的。伴隨著自由軟件發展的強大動力,我們有理由相信Apache的未來是一片光明的。
在Internet時代,外部主頁的發布已經成為樹立公司形象的一個重要手段,而內部主頁也成為公司管理的主要方式。但是,要想實現這些功能,首先應該把我們的Linux Server配置成為一台強大的Web Server。時至今日,全球應用最廣泛的Web服務器軟件就是Apache,本章將詳細介紹如何配置Apache服務器。希望各位同仁能夠通過閱讀本片文章達到理論實踐雙豐收的目的,在很短的時間裡迅速成為一名出色的網絡管理員。


1.2 所需資源

1.2.1 所需包
RedHat6.2 服務器安裝

1.2.2 所需配置文件
/etc/httpd/conf/httpd.conf 系統自帶,管理員配置
/etc/httpd/conf/Access.conf 系統自帶,不需要修改
/etc/httpd/conf/srm.conf 系統自帶,不需要修改


1.3 配置方案

/etc/httpd/conf/httpd.conf
說明:apache主配置文件
源文件:
ServerType standalone
    #定義WebServer的啟動方式為standalone,以增強其對大量訪問的及時響應性
ServerRoot "/etc/httpd"
    #指定包含httpd服務器文件的目錄
LockFile /var/lock/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile /var/run/httpd.scoreboard
Timeout 300
    #響應超時量,單位為秒
KeepAlive On
    #允許用戶建立永久連接
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
    #要保留的空閒服務器進程的最小值
MaxSpareServers 20
    #要保留的空閒服務器進程的最大值
StartServers 8
    #系統啟動時的守護進程數
MaxClients 150
    #所能提供服務的最大客戶端編號,大於它的部分被放入請求隊列
MaxRequestsPerChild 100
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule env_module     modules/mod_env.so
LoadModule config_log_module modules/mod_log_config.so
LoadModule agent_log_module  modules/mod_log_agent.so
LoadModule referer_log_module modules/mod_log_referer.so
LoadModule mime_module    modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule status_module   modules/mod_status.so
LoadModule info_module    modules/mod_info.so
LoadModule includes_module  modules/mod_include.so
LoadModule autoindex_module  modules/mod_autoindex.so
LoadModule dir_module     modules/mod_dir.so
LoadModule cgi_module     modules/mod_cgi.so
LoadModule asis_module    modules/mod_asis.so
LoadModule imap_module    modules/mod_imap.so
LoadModule action_module   modules/mod_actions.so
LoadModule userdir_module   modules/mod_userdir.so
LoadModule alias_module    modules/mod_alias.so



LoadModule rewrite_module   modules/mod_rewrite.so
LoadModule access_module   modules/mod_access.so
LoadModule auth_module    modules/mod_auth.so
LoadModule anon_auth_module  modules/mod_auth_anon.so
LoadModule db_auth_module   modules/mod_auth_db.so
LoadModule digest_module   modules/mod_digest.so
LoadModule proxy_module    modules/libproxy.so
LoadModule eXPires_module   modules/mod_expires.so
LoadModule headers_module   modules/mod_headers.so
LoadModule usertrack_module  modules/mod_usertrack.so
LoadModule setenvif_module  modules/mod_setenvif.so
LoadModule perl_module    modules/libperl.so
LoadModule PHP3_module    modules/libphp3.so
ClearModuleList
AddModule mod_vhost_alias.c
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_log_agent.c
AddModule mod_log_referer.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_info.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
#AddModule mod_speling.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_auth_anon.c
AddModule mod_auth_db.c
AddModule mod_digest.c
AddModule mod_proxy.c
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_usertrack.c
AddModule mod_so.c
AddModule mod_setenvif.c
AddModule mod_perl.c
AddModule mod_php3.c
Port 80
    #定義服務器所使用的TCP的端口號
User nobody
Group nobody
    #以上兩行是分配給httpd的新用戶的文件權限,出於安全的考慮把
    它們的權限設置成為最低。
ServerAdmin [email protected]
    #設置Web管理員的郵件地址
ServerName WebOA
    #定義客戶端從服務器讀取數據時返回給客戶端的主機名,其缺省值
    是localhost,第一次安裝Linux的時候經常這裡出錯。
DocumentRoot "/home/weboa/jakarta-tomcat/webapps/weboa"
    #設置所有Apache文檔的根目錄,比如說,用戶對
    http://www.weboa.com.cn/index.Html的訪問請求,Apache對它
    的響應是/home/weboa/jakarta-tomcat/webapps/weboa/index.html

    Options FollowSymLinks
    AllowOverride None


    Options Indexes Includes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all      # 允許所有人訪問

UserDir public_html
DirectoryIndex index.html index.htm index.shtml index.cgi


    #設置多種成功訪問主頁的方式,為的是提高系統的容錯性
AccessFileName .htaccess

    Order allow,deny
    Deny from all

UseCanonicalName On
TypesConfig /etc/mime.types
DefaultType text/plain

    MIMEMagicFile share/magic

HostnameLookups Off
ErrorLog /usr/httpd/log/error_log
LogLevel warn
    #定義那些錯誤類型被記錄到錯誤日志中
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    #所有的LogFormat都用來定義日志中的條目
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/httpd/log/access_log common
ServerSignature On
Alias /icons/ "/home/httpd/icons/"
#定義虛擬主機目錄與系統目錄的對應關系

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
#定義CGI目錄

    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all

IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/



LogLevel warn
    #定義那些錯誤類型被記錄到錯誤日志中
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    #所有的LogFormat都用來定義日志中的條目
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/httpd/log/access_log common
ServerSignature On
Alias /icons/ "/home/httpd/icons/"
#定義虛擬主機目錄與系統目錄的對應關系

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
#定義CGI目錄

    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all

IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/



Copyright © Linux教程網 All Rights Reserved