<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服務(wù)器軟件,由apache software foundation 開發(fā)和維護(hù)的。它是目前世界上使用最為廣泛的web服務(wù)器軟件,支持各種unix平臺和windows平臺。本文將介紹它在Red hat Linux 9中最基本的安裝和配置。

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

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

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

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

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

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

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

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

    /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.啟動:

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


    如果不出什么問題,ps aux 應(yīng)該可以查到httpd 的進(jìn)程,或netstat -an 也可以看到80端口的服務(wù)已經(jīng)起來了。如果要設(shè)置開機(jī)自啟動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)值,接下來我介紹介紹一些常用的配置項:









    # 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 的偵聽地址和端口。

    #
    # 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 的文檔根目錄,必須是絕對路徑。

    <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的根目錄,必須是絕對路徑。

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


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

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

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

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

    2.如果網(wǎng)站的訪問量不是很大可以考慮用xinetd超級進(jìn)程來啟動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的支持

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

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

    Listen 80


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

    Listen [::]:80


    這樣 apache 就可以區(qū)別對待 IPV4 與IPV6的連接了。
    主站蜘蛛池模板: 亚洲欧美日韩一区二区三区| 狠狠色伊人亚洲综合网站色| 四虎永久在线精品免费一区二区| 在线观看免费人成视频色| 亚洲黄网在线观看| 1000部国产成人免费视频| 亚洲国产美女精品久久| 免费可以在线看A∨网站| 亚洲成a人无码亚洲成www牛牛| 日本人护士免费xxxx视频| 国产亚洲人成在线影院| 免费A级毛片无码A∨男男| 特级毛片全部免费播放| 国产亚洲精品拍拍拍拍拍| 精品免费视在线观看| 亚洲性69影院在线观看| 免费的一级片网站| 精品在线视频免费| 久久精品国产亚洲网站| 亚洲一区在线免费观看| 亚洲精品国产suv一区88| 精品国产亚洲一区二区在线观看 | 天天影视色香欲综合免费| 亚洲日本香蕉视频| 日美韩电影免费看| 久久久免费观成人影院| 久久av无码专区亚洲av桃花岛| 国产精品视频永久免费播放| 美女免费视频一区二区| 久久精品国产亚洲麻豆| 国内免费高清在线观看| 国产精品内射视频免费| 久久久久亚洲精品天堂| 在线免费观看韩国a视频| a级毛片免费在线观看| 亚洲三级视频在线| 国产亚洲精品不卡在线| 午夜免费1000部| 国产精品1024在线永久免费| 亚洲毛片在线免费观看| 国产精品亚洲美女久久久 |