<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    海鷗航際

    JAVA站
    posts - 11, comments - 53, trackbacks - 1, articles - 102
    一.、Apache web server 簡(jiǎn)介

    Apache web server是一款開(kāi)放源碼的web服務(wù)器軟件,由apache software foundation 開(kāi)發(fā)和維護(hù)的。它是目前世界上使用最為廣泛的web服務(wù)器軟件,支持各種unix平臺(tái)和windows平臺(tái)。本文將介紹它在Red hat Linux 9中最基本的安裝和配置。

    二、軟件的相關(guān)資源

    官方網(wǎng)站:http://httpd.apache.org/
    源碼軟件包:Apache 是開(kāi)源的軟件,可以去其官方網(wǎng)站http://httpd.apache.org/download.cgi下載。目前的最新穩(wěn)定版本是httpd-2.0.53。
    幫助文檔:http://httpd.apache.org/docs-project/ 有該軟件比較全面的幫助文檔。
    FAQ:http://httpd.apache.org/docs/misc/FAQ.html 回答了該軟件的常見(jiàn)問(wèn)題。
    三.軟件的安裝

    1.安裝

    由其官方網(wǎng)站中下載其源碼軟件包httpd-2.0.53.tar.gz。接下來(lái)我將對(duì)安裝過(guò)程的一些重要步驟,給出其解釋?zhuān)?BR>
    [root@localhost root]#tar xzvf httpd-2.0.53.tar.gz
    [root@localhost root]#cd httpd-2.0.53
    [root@localhost httpd-2.0.53]#./configure
    [root@localhost httpd-2.0.53]#make
    [root@localhost httpd-2.0.53]#make install


    tar xzvf httpd-2.0.53.tar.gz 解壓縮軟件包。

    ./configure 針對(duì)機(jī)器作安裝的檢查和設(shè)置,大部分的工作是由機(jī)器自動(dòng)完成的,但是用戶(hù)可以通過(guò)一些參數(shù)來(lái)完成一定的設(shè)置,其常用選項(xiàng)有:

    ./configure --help 察看參數(shù)設(shè)置幫助。

    --prefix= 指定軟件安裝目錄(默認(rèn)/usr/local/apache2)。

    --enable-modules= 指定需要加載的模塊。

    --enable-v4-mapped 支持ipv6的socket處理ipv4的連接。

    可以設(shè)置的參數(shù)很多,可以通過(guò) -help察看需要的,一般情況下,默認(rèn)設(shè)置就可以了。

    默認(rèn)安裝建立了/usr/local/apache2目錄,下面介紹一下/usr/local/apache2的幾個(gè)常用組成部分:

    /usr/local/apache2/bin 其中主要是有服務(wù)器的程序。常用的有deamon程序httpd,和控制腳本apachectl。

    /usr/local/apache2/conf 其中主要是服務(wù)器相關(guān)的配置文件。最主要的配置文件是httpd.conf。

    /usr/local/apache2/htdocs 默認(rèn)的網(wǎng)站html文件根目錄。

    /usr/local/apache2/cgi-bin 默認(rèn)的cgi程序的存放目錄。

    2.啟動(dòng):

    [root@localhost root]# /usr/local/apache2/bin/apachectl start
    [root@localhost root]# ps aux 
    [root@localhost root]# netstat -an


    如果不出什么問(wèn)題,ps aux 應(yīng)該可以查到httpd 的進(jìn)程,或netstat -an 也可以看到80端口的服務(wù)已經(jīng)起來(lái)了。如果要設(shè)置開(kāi)機(jī)自啟動(dòng)web server,只需在/etc/rc.d/rc.local中加入一行

    /usr/local/apache2/bin/apachectl start

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    touch /var/lock/subsys/local
    
    /usr/local/apache2/bin/apachectl start

    四、軟件的配置。

    /usr/local/apache2/conf/httpd.conf 默認(rèn)安裝,所有的配置都有其默認(rèn)值,接下來(lái)我介紹介紹一些常用的配置項(xiàng):









    # Listen: Allows you to bind Apache to specific IP addresses and/or
    # ports, instead of the default. See also the <VirtualHost>
    # directive.
    #
    # Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
    #
    #Listen 12.34.56.78:80
    
    Listen 80


    設(shè)定apache 的偵聽(tīng)地址和端口。

    #
    # 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 you@example.com


    設(shè)定apache 的管理員郵件地址。

    #
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot "/usr/local/apache2/htdocs"


    設(shè)定apache web server 的文檔根目錄,必須是絕對(duì)路徑。

    <Directory "/usr/local/apache2/htdocs">
    
    #
    # 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
    
    #
    # 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
    
    #
    # Controls who can get stuff from this server.
    #
        Order allow,deny
        Allow from all
    
    </Directory>


    設(shè)定文檔根目錄的權(quán)限控制,必須和DocumentRoot "/usr/local/apache2/htdocs" 中指定的目錄一致。

    #
    # The index.html.var file (a type-map) is used to deliver content-
    # negotiated documents.  The MultiViews Option can be used for the
    # same purpose, but it is much slower.
    #
    DirectoryIndex index.html


    指定該目錄下的索引文檔,

    ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"


    映射cgi-bin的根目錄,必須是絕對(duì)路徑。

    <Directory "/usr/local/apache2/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>


    設(shè)定cgi-bin目錄的讀寫(xiě)權(quán)限,該目錄項(xiàng)必須和上一條的設(shè)置一致。

    五.安裝使用的一些經(jīng)驗(yàn):

    1.apache 進(jìn)程的有效用戶(hù)id默認(rèn)為nobody。

    出于安全方面的考慮,apache 服務(wù)器進(jìn)程的默認(rèn)有效 id 被設(shè)置為nobody,這就意味著該進(jìn)程只擁有nobody的權(quán)限,所以必須確保nobody對(duì)設(shè)置的DocumentRoot 有足夠權(quán)限。或者可以配置apache進(jìn)程的有效id,但是推薦不要這樣做。

    2.如果網(wǎng)站的訪(fǎng)問(wèn)量不是很大可以考慮用xinetd超級(jí)進(jìn)程來(lái)啟動(dòng)apache

    (1)打開(kāi)/usr/local/apache2/conf/httpd.conf,修改

    ServerType inetd


    (2)創(chuàng)建/etc/xinetd.d/apache,內(nèi)容:

    # default: on
    # description: The Apache HTTP connections.
    service http
    {
    disable = no
    socket_type = stream
    wait = no
    user = root
    server = /usr/sbin/httpd
    port = 80
    # log_on_success += DURATION USERID
    # log_on_failure += USERID
    # nice = 10
    }


    (3)重新啟動(dòng)xinetd:

    #/etc/rc.d/init.d/xinetd restart


    3.對(duì)IPV6的支持

    隨著計(jì)算機(jī)網(wǎng)絡(luò)的不斷發(fā)展和擴(kuò)大,IPV6已經(jīng)越來(lái)越為人們所接受,apache自2.0之后的版本開(kāi)始支持IPV6,下面我就簡(jiǎn)單介紹一下apache針對(duì)ipv6的配置:

    默認(rèn)情況下,apache 使用映射到IPv4的IPv6地址,即安裝配置時(shí),默認(rèn)./configure -enable-v4-map ,并且在配置文件http.conf中將是:

    Listen 80


    要使apache 區(qū)別對(duì)待IPV4與IPV6的連接,安裝配置時(shí),使用 ./configure -disable-v4-map , 對(duì)應(yīng)配置文件中http.conf :

    Listen [::]:80


    這樣 apache 就可以區(qū)別對(duì)待 IPV4 與IPV6的連接了。
    主站蜘蛛池模板: 亚洲国产美女福利直播秀一区二区| 综合亚洲伊人午夜网 | 黄色网址免费观看| 国产∨亚洲V天堂无码久久久| 日韩精品无码免费视频| 免费在线观看中文字幕| 一个人免费观看日本www视频| www.亚洲一区| 免费福利在线观看| 亚洲成a人片在线播放| 一区二区三区免费在线视频| 亚洲性在线看高清h片| 黄 色一级 成 人网站免费| 在线观看亚洲电影| 免费看美女被靠到爽| 国产综合激情在线亚洲第一页 | 中文字幕乱码系列免费| 亚洲VA中文字幕无码毛片| 久久精品私人影院免费看| 亚洲第一永久在线观看| 99无码人妻一区二区三区免费| 亚洲日本人成中文字幕| 手机看片久久国产免费| fc2成年免费共享视频网站| 亚洲AV永久纯肉无码精品动漫| 91精品国产免费入口| 亚洲日韩AV一区二区三区四区| 国产hs免费高清在线观看| 中国黄色免费网站| 亚洲精品中文字幕麻豆| 日本特黄特黄刺激大片免费| 老司机精品免费视频| 亚洲一卡2卡4卡5卡6卡在线99| 国产一级高清免费观看| a级片免费观看视频| 亚洲丰满熟女一区二区v| 高清在线亚洲精品国产二区| 无码日韩精品一区二区三区免费| 亚洲最大av资源站无码av网址| 久久综合亚洲色HEZYO国产| 91久久成人免费|