<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 簡介

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

    二、軟件的相關資源

    官方網(wǎng)站:http://httpd.apache.org/
    源碼軟件包:Apache 是開源的軟件,可以去其官方網(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 回答了該軟件的常見問題。
    三.軟件的安裝

    1.安裝

    由其官方網(wǎng)站中下載其源碼軟件包httpd-2.0.53.tar.gz。接下來我將對安裝過程的一些重要步驟,給出其解釋:

    [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 針對機器作安裝的檢查和設置,大部分的工作是由機器自動完成的,但是用戶可以通過一些參數(shù)來完成一定的設置,其常用選項有:

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

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

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

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

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

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

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

    /usr/local/apache2/conf 其中主要是服務器相關的配置文件。最主要的配置文件是httpd.conf。

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

    /usr/local/apache2/cgi-bin 默認的cgi程序的存放目錄。

    2.啟動:

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


    如果不出什么問題,ps aux 應該可以查到httpd 的進程,或netstat -an 也可以看到80端口的服務已經(jī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 默認安裝,所有的配置都有其默認值,接下來我介紹介紹一些常用的配置項:









    # 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


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


    設定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"


    設定apache web server 的文檔根目錄,必須是絕對路徑。

    <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>


    設定文檔根目錄的權限控制,必須和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的根目錄,必須是絕對路徑。

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


    設定cgi-bin目錄的讀寫權限,該目錄項必須和上一條的設置一致。

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

    1.apache 進程的有效用戶id默認為nobody。

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

    2.如果網(wǎng)站的訪問量不是很大可以考慮用xinetd超級進程來啟動apache

    (1)打開/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)重新啟動xinetd:

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


    3.對IPV6的支持

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

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

    Listen 80


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

    Listen [::]:80


    這樣 apache 就可以區(qū)別對待 IPV4 與IPV6的連接了。
    主站蜘蛛池模板: 国产精品亚洲高清一区二区| 8x成人永久免费视频| 亚洲一区二区三区高清视频| 国产成人AV片无码免费| 亚洲色精品vr一区二区三区 | 亚洲伊人久久综合中文成人网| 欧美激情综合亚洲一二区| 免费无遮挡无码视频网站| 亚洲精品国产suv一区88| 91视频免费观看| 日韩在线视频免费看| 亚洲精品无码国产片| 免费人成网站在线高清| 亚洲一区二区影视| 日韩免费视频观看| 猫咪免费人成在线网站| 女人张开腿等男人桶免费视频| 亚洲av综合色区| 色爽黄1000部免费软件下载| 亚洲精品无码99在线观看| 99re8这里有精品热视频免费| 亚洲AV无码一区东京热久久| 99热在线免费观看| 亚洲综合无码无在线观看| a成人毛片免费观看| 亚洲综合久久久久久中文字幕| 无码国产精品一区二区免费I6| 亚洲av永久中文无码精品综合| 免费国产成人高清在线观看麻豆 | 13小箩利洗澡无码视频网站免费 | 国产天堂亚洲国产碰碰| 亚洲一区二区视频在线观看| 97国产在线公开免费观看| 亚洲午夜理论片在线观看| 一本色道久久综合亚洲精品高清| 少妇无码一区二区三区免费| 国产成人综合亚洲亚洲国产第一页 | 在线看片免费人成视频久网下载| 亚洲色图.com| 4399影视免费观看高清直播| 亚洲AV乱码久久精品蜜桃|