apache2を使おう!

  1. 材料
  2. apache2のインストール
    % ./configure
    % make
    % su
    # make install
    
  3. apache2の設定

    以下はapacheのユーザとグループの設定です。

    ***************
    *** 263,270 ****
      #  when the value of (unsigned)Group is above 60000; 
      #  don't use Group #-1 on these systems!
      #
    ! User nobody
    ! Group #-1
      </IfModule>
      </IfModule>
      
    --- 263,270 ----
      #  when the value of (unsigned)Group is above 60000; 
      #  don't use Group #-1 on these systems!
      #
    ! User www
    ! Group www
      </IfModule>
      </IfModule>
      
    
    以下はサーバの情報に関する設定です。
    ***************
    *** 273,279 ****
      # e-mailed.  This address appears on some server-generated pages, such
      # as error documents.  e.g. admin@your-domain.com
      #
    ! ServerAdmin you@your.address
      
      #
      # ServerName gives the name and port that the server uses to identify itself.
    --- 273,279 ----
      # e-mailed.  This address appears on some server-generated pages, such
      # as error documents.  e.g. admin@your-domain.com
      #
    ! ServerAdmin webmaster@ykondou.org
      
      #
      # ServerName gives the name and port that the server uses to identify itself.
    ***************
    *** 287,293 ****
      # 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
      
      #
      # UseCanonicalName: Determines how Apache constructs self-referencing 
    --- 287,293 ----
      # You will have to access it by its address anyway, and this will make 
      # redirections work in a sensible way.
      #
    ! ServerName www.ykondou.org
      
      #
      # UseCanonicalName: Determines how Apache constructs self-referencing 
    ***************
    *** 296,309 ****
      # by the client.  When set "On", Apache will use the value of the
      # ServerName directive.
      #
    ! UseCanonicalName Off
      
      #
      # 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"
      
      #
      # Each directory to which Apache has access can be configured with respect
    --- 296,309 ----
      # by the client.  When set "On", Apache will use the value of the
      # ServerName directive.
      #
    ! UseCanonicalName On
      
      #
      # 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/www"
      
      #
      # Each directory to which Apache has access can be configured with respect
    ***************
    *** 328,334 ****
      #
      # This should be changed to whatever you set DocumentRoot to.
      #
    ! <Directory "/usr/local/apache2/htdocs">
      
      #
      # Possible values for the Options directive are "None", "All",
    --- 328,334 ----
      #
      # This should be changed to whatever you set DocumentRoot to.
      #
    ! <Directory "/usr/local/apache2/www">
      
      #
      # Possible values for the Options directive are "None", "All",
    
    以下はanalogでログを解析するための設定です。ローカルのネットワークからのアクセスを解析しないように、ログ出力の制限を行なっています。
    ***************
    *** 498,504 ****
      # define per- access logfiles, transactions will be
      # logged therein and *not* in this file.
      #
    ! CustomLog logs/access_log common
      
      #
      # If you would like to have agent and referer logfiles, uncomment the
    --- 503,509 ----
      # define per- access logfiles, transactions will be
      # logged therein and *not* in this file.
      #
    ! #CustomLog logs/access_log common
      
      #
      # If you would like to have agent and referer logfiles, uncomment the
    ***************
    *** 511,517 ****
      # If you prefer a single logfile with access, agent, and referer information
      # (Combined Logfile Format) you can use the following directive.
      #
    ! #CustomLog logs/access_log combined
      
      #
      # ServerTokens
    --- 516,523 ----
      # If you prefer a single logfile with access, agent, and referer information
      # (Combined Logfile Format) you can use the following directive.
      #
    ! SetEnvIf Remote_Addr 192.168.0. no_log
    ! CustomLog logs/access_log combined env=!no_log
      
      #
      # ServerTokens
    
    ***************
    *** 531,537 ****
      # Set to "EMail" to also include a mailto: link to the ServerAdmin.
      # Set to one of:  On | Off | EMail
      #
    ! ServerSignature On
      
      #
      # Aliases: Add here as many aliases as you need (with no limit). The format is
     
    --- 537,543 ----
      # Set to "EMail" to also include a mailto: link to the ServerAdmin.
      # Set to one of:  On | Off | EMail
      #
    ! ServerSignature EMail
      
      #
      # Aliases: Add here as many aliases as you need (with no limit). The format is
     
    
    以下は、apache2から導入された設定です。 コンテンツに含まれる言語が単一の場合、AddDefaultCharsetにその言語を設定します。複数の言語を含む場合には、AddDefaultCharsetにnoneを設定し、コンテンツのmetaタグに設定します。例えば、以下の通りです。
    <meta http-equiv="CONTENT-TYPE" content="text/html charset=ISO-2022-JP">
    
    以下の設定では、日本語の優先順位をあげて、AddDefaultCharsetにnoneを設定しています。
    ***************
    *** 760,766 ****
      # 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 da nl et fr de el it ja ko no pl pt pt-br ltz ca es sv tw
      
      #
      # ForceLanguagePriority allows you to serve a result page rather than
    --- 767,773 ----
      # Just list the languages in decreasing order of preference. We have
      # more or less alphabetized them here. You probably want to change this.
      #
    ! LanguagePriority ja en da nl et fr de el it ko no pl pt pt-br ltz ca es sv tw
      
      #
      # ForceLanguagePriority allows you to serve a result page rather than
    ***************
    *** 779,785 ****
      # reasons in browsers, related to javascript and URL parsing
      # which encourage you to always set a default char set.
      #
    ! AddDefaultCharset ISO-8859-1
      
      #
      # Commonly used filename extensions to character sets. You probably
    --- 787,793 ----
      # reasons in browsers, related to javascript and URL parsing
      # which encourage you to always set a default char set.
      #
    ! AddDefaultCharset none
      
      #
      # Commonly used filename extensions to character sets. You probably
    
    以下はSSIの設定です。
    ***************
    *** 314,320 ****
      # features.  
      #
      
    !     Options FollowSymLinks
          AllowOverride None
      
      
    --- 314,320 ----
      # features.  
      #
      
    !     Options FollowSymLinks Includes
          AllowOverride None
      
      
    ***************
    *** 342,348 ****
      # 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.
    --- 342,348 ----
      # http://httpd.apache.org/docs-2.0/mod/core.html#options
      # for more information.
      #
    !     Options Indexes FollowSymLinks Includes
      
      #
      # AllowOverride controls what directives may be placed in .htaccess files.
    ***************
    *** 390,396 ****
      # negotiated documents.  The MultiViews Option can be used for the 
      # same purpose, but it is much slower.
      #
    ! DirectoryIndex index.html index.html.var
      
      #
      # AccessFileName: The name of the file to look for in each directory
    --- 395,401 ----
      # negotiated documents.  The MultiViews Option can be used for the 
      # same purpose, but it is much slower.
      #
    ! DirectoryIndex index.html index.html.var index.shtml
      
      #
      # AccessFileName: The name of the file to look for in each directory
    ***************
    *** 867,874 ****
      # To parse .shtml files for server-side includes (SSI):
      # (You will also need to add "Includes" to the "Options" directive.)
      #
    ! #AddType text/html .shtml
    ! #AddOutputFilter INCLUDES .shtml
      
      #
      # Action lets you define media types that will execute a script whenever
    --- 876,883 ----
      # To parse .shtml files for server-side includes (SSI):
      # (You will also need to add "Includes" to the "Options" directive.)
      #
    ! AddType text/html .shtml
    ! AddOutputFilter INCLUDES .shtml
      
      #
      # Action lets you define media types that will execute a script whenever
    
  4. apache2の起動

    まず、設定に間違いがないかどうかを確認します。

    # /usr/local/apache2/bin/apachectl configtest
    Syntax OK
    
    上記のように出力されれば問題ありません。違った結果が得られた場合は、設定ファイルを確認・修正します。問題のないことを確認したら、apache2を起動します。
    # /usr/local/apache2/bin/apachectl start
    


Copyright(C) 2001-2008 ykondou.org
webmaster@ykondou.org
Key fingerprint = 7721 FB0E 42CC 2BD3 DB09 5868 3EC7 B5D2 B75C 5DAA

Valid CSS! Valid HTML 4.01!