歡迎您光臨本站 註冊首頁

redhat enterprise linux 5下apache部署及簡單的配置過程

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0
redhat enterprise linux 5下apache部署及簡單的配置過程
實驗環境 VMware 6.5.2 redhat enterprise linux 5
及此前做完的DNS服務
實驗開始 】
我的內核版本
windows系統發布一個建易得網頁可以選擇IIS ,安裝並不困難,linux下則可以選擇apache ,
www服務遵循http協議,使用http超文本標記語言故
apache的 守護進程名 httpd
apache的默認埠 80
相關文件 /etc/httpd/
/etc/httpd/conf/httpd.conf 配置文件
掛鏡像 安裝apache 所需的rpm包
cd /m[root@localhost ~]# cd /mnt/cdrom
[root@localhost cdrom]# cd Server
[root@localhost Server]# rpm -ivh httpd-
httpd-2.2.3-11.el5.i386.rpm httpd-manual-2.2.3-11.el5.i386.rpm
httpd-devel-2.2.3-11.el5.i386.rpm
[root@localhost Server]# rpm -ivh httpd-2.2.3-11.el5.i386.rpm
warning: httpd-2.2.3-11.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package httpd-2.2.3-11.el5 is already installed
[root@localhost Server]#
此包已經裝過
[root@localhost Server]# rpm -ivh httpd-devel-2.2.3-11.el5.i386.rpm
warning: httpd-devel-2.2.3-11.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
apr-devel is needed by httpd-devel-2.2.3-11.el5.i386
apr-util-devel is needed by httpd-devel-2.2.3-11.el5.i386
[root@localhost Server]# rpm -ivh apr-devel-1.2.7-11.i386.rpm
warning: apr-devel-1.2.7-11.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:apr-devel ########################################### [100%]

#EnableMMAP off
#
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. Please see
# [url]http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile[/url]
#
#EnableSendfile off
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog logs/error_log
錯誤日誌存放位置
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
指定記錄的錯誤信息的詳細等級為warn 級別
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
幾種記錄日誌的格式
LogFormat "%h %l %u %t "%r" %&gt;s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %&gt;s %b" common
LogFormat "%{Referer}i -&gt; %U" referer
LogFormat "%{User-agent}i" agent
# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this
# requires the mod_logio module to be loaded.
#LogFormat "%h %l %u %t "%r" %&gt;s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio

# clients where to look for the relocated document.
# Example:
# Redirect permanent /foo [url]http://www.example.com/bar[/url]
#
# Directives controlling the display of server-generated directory listings.
#
#
# IndexOptions: Controls the appearance of server-generated directory
# listings.
#
IndexOptions FancyIndexing VersionSort Name HTMLTable
#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions. These are only displayed for
# FancyIndexed directories.
#
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/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
#

# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
#
DefaultIcon /icons/unknown.gif
#
# AddDescription allows you to place a short description after a file in
# server-generated indexes. These are only displayed for FancyIndexed
# directories.
# Format: AddDescription "description" filename
#
#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz
#
# ReadmeName is the name of the README file the server will look for by
# default, and append to directory listings.
#
# HeaderName is the name of a file which should be prepended to
# directory indexes.
ReadmeName README.html
HeaderName HEADER.html
#
# IndexIgnore is a set of filenames which directory indexing should ignore
# and not include in the listing. Shell-style wildcarding is permitted.
#
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
#
# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
# DefaultLanguage nl

#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character 'Language' abbreviation is not identical to
# the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
#
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
# specifier. There is 'work in progress' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
# Norwegian (no) - Polish (pl) - Portugese (pt)
# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
#
對中文網頁以下幾項無實際意義
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl

AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback
#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8
默認字符集 UTF-8
#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
#AddType application/x-tar .tgz
添加新的MIME類型
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.

# Format: Action handler-name /cgi-script/location
#
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 [url]http://www.example.com/subscription_info.html[/url]
#
#
# Putting this all together, we can internationalize error responses.
#
# We use Alias to redirect any /error/HTTP_<error>.html.var response to
# our collection of by-error message multi-language collections. We use
# includes to substitute the appropriate text.
#
# You can modify the messages' appearance without changing any of the
# default HTTP_<error>.html.var files by adding the line:
#
# Alias /error/include/ "/your/include/path/"
#
# which allows you to create your own set of files by starting with the
# /var/www/error/include/ files and
# copying them to /your/include/path/, even on a per-VirtualHost basis.
#
Alias /error/ "/var/www/error/"
設置/var/www/error/的訪問許可權
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
<Directory "/var/www/error">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback
</Directory>
# ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
# ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

5.0.168.192.in-addr.arpa name = [url]www.sina.com.[/url]
[root@localhost named]#
確保能正確解析后
我們來嘗試著做一下虛擬主機
[root@localhost named]# vi /etc/httpd/conf/httpd.conf
972 NameVirtualHost 192.168.0.5 (基於名字的虛擬主機)刪除# 意為啟用
<VirtualHost 192.168.0.5>
ServerAdmin webmaster@abc.com
DocumentRoot /tmp/www.abc
ServerName [url]www.abc.com[/url]
ErrorLog logs/abc.com-error_log
CustomLog logs/abc.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.5>
ServerAdmin webmaster@sina.com
DocumentRoot /tmp/www.sina
ServerName [url]www.sina.com[/url]
ErrorLog logs/sina.com-error_log
CustomLog logs/sina.com-access_log common
</VirtualHost>
原來內容不變添加內容如上,保存退出
[root@localhost tmp]# mkdir [url]www.sina[/url]
[root@localhost tmp]# mkdir [url]www.abc[/url]
[root@localhost tmp]# cd [url]www.sina[/url]
[root@localhost [url]www.sina[/url]]# vi index.html
保存退出
[root@localhost [url]www.sina[/url]]# cd ..
[root@localhost tmp]# cd [url]www.abc[/url]
[root@localhost [url]www.abc[/url]]# vi index.html
隨便輸入點什麼內容,能分出來就行
[root@localhost [url]www.abc[/url]]# service httpd restart
停止 httpd: [確定]
啟動 httpd:[Fri May 01 22:30:46 2009] [warn] VirtualHost 192.168.0.5:0 overlaps with VirtualHost 192.168.0.5:0, the first has precedence, perhaps you need a NameVirtualHost directive
[確定]
[root@localhost [url]www.abc[/url]]#
ok [url]www.abc.com[/url] 已經解析出來

今天就為大家介紹到這裡,文中有不到之處還望多多指教!!!


[火星人 ] redhat enterprise linux 5下apache部署及簡單的配置過程已經有687次圍觀

http://coctec.com/docs/linux/show-post-53788.html