梁小芳的記事本

「上大聯盟不是夢想,是我的目標。」-松坂大輔

« 上一篇 | 下一篇»

服務器更安全
文章作者: plrts @ 文章發表日期: 2008年 八月 19日 星期二 20:03:07
編輯Apache的設定檔
#
# Don't give away too much information about all the subcomponents
# we are running. Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running

ServerTokens OS
← 找到這一行,將“OS”改為“Prod”(在出現錯誤頁的時候不顯示服務器操作繫統的名稱)

ServerTokens Prod ← 變為此狀態

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#

ServerSignature On
← 找到這一行,將“On”改為“Off”

ServerSignature Off ← 在錯誤頁中不顯示Apache的版本

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#

ServerAdmin root@localhost
← 將管理員郵箱設置為自己常用的電子郵件

ServerAdmin yourname@yourserver.com ← 根據實際情況修改預設值

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work. See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#

#ServerName new.host.name:80
← 修改主機名

ServerName www.centospub.com:80 ← 根據實際情況修改,端口號保持默認的80

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#

Options Indexes FollowSymLinks
← 找到這一行,刪除“Indexes”,並添加“Includes”、“ExecCGI”

Options Includes ExecCGI FollowSymLinks
← 允許執行CGI及SSI

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#

#AddHandler cgi-script .cgi
← 找到這一行,去掉行首的“#”,並在行尾添加“.pl”

AddHandler cgi-script .cgi .pl ← 允許擴展名為.pl的CGI腳本運行

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#

AllowOverride None
← 找到這一行,將“None”改為“All”

AllowOverride All ← 變為此狀態,允許.htaccess

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
← 找到這一行

LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined ← 改為此狀態(添加“!414”到規則中,對於過長的日志不記錄)

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#

AddDefaultCharset UTF-8
← 找到這一行,在行首添加“#”

#AddDefaultCharset UTF-8
← 不使用UTF-8作為網頁的默認編碼,由網頁上的指定語系決定


<Directory "/var/www/icons"> ← 找到這一個標簽,並在標簽中更改相應選項
Options Indexes MultiViews ← 找到這一行,將“Indexes”刪除

Options MultiViews ← 變為此狀態(不在瀏覽器上顯示樹狀目錄結構)

AllowOverride None
Order allow,deny
Allow from all
</Directory>
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS