>> HOME >> FC5 MENU >> Webサーバー (Apache)
Apache とは世界で最も普及している Web Server(ホームページを公開する機能)で無料で入手する事ができます。
Apache には 1.3系と 2.0系が公開されており、主な違いは 2.0系が マルチスレッド で動作すると言うことらしいです。

1. Apache のインストール
1 ) httpd のインストール
2 ) PHP のインストール
2. Apache の設定
1 ) httpd 設定ファイル /etc/httpd/conf/httpd.conf の編集
3. CGIを実行するPerlのシンボリックリンクを貼る(FreeのCGIを使用する際の対応)
4. Apache の起動
1 ) httpd の起動
2 ) httpd の自動起動設定
5. Apache の動作確認
1 ) Windowsクライアントから実施(ブラウザ)
2 ) テストページの削除
6. 公開前の準備
1. Apache のインストール
1 ) httpd のインストール
[root@linux ~]# yum -y install httpd 
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core                                                                 [1/3]
core                      100% |=========================| 1.1 kB    00:00
updates                                                              [2/3]
updates                   100% |=========================|  951 B    00:00
extras                                                               [3/3]
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for httpd to pack into transaction set.
httpd-2.2.2-1.0.i386.rpm  100% |=========================|  80 kB    00:00
---> Package httpd.i386 0:2.2.2-1.0 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 httpd                   i386       2.2.2-1.0        updates           1.1 M

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 1.1 M
Downloading Packages:
(1/1): httpd-2.2.2-1.0.i3 100% |=========================| 1.1 MB    00:04
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: httpd                        ######################### [1/1]

Installed: httpd.i386 0:2.2.2-1.0
Complete!
2 ) PHP のインストール
[root@linux ~]# yum -y install php 
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core                                                                 [1/4]
crash-hat                                                            [2/4]
extras                                                               [3/4]
updates                                                              [4/4]
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php to pack into transaction set.
php-5.1.2-5.i386.rpm      100% |=========================|  21 kB    00:00
---> Package php.i386 0:5.1.2-5 set to be updated
--> Running transaction check
--> Processing Dependency: php-pear for package: php
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-pear to pack into transaction set.
php-pear-1.4.6-2.1.noarch 100% |=========================|  23 kB    00:00
---> Package php-pear.noarch 1:1.4.6-2.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 php                     i386       5.1.2-5          core              3.5 M
Installing for dependencies:
 php-pear                noarch     1:1.4.6-2.1      updates           351 k

Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 3.8 M
Downloading Packages:
(1/2): php-pear-1.4.6-2.1 100% |=========================| 351 kB    00:00
(2/2): php-5.1.2-5.i386.r 100% |=========================| 3.5 MB    00:03
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: php                          ######################### [1/2]
  Installing: php-pear                     ######################### [2/2]

Installed: php.i386 0:5.1.2-5
Dependency Installed: php-pear.noarch 1:1.4.6-2.1
Complete!
2. Apache の設定
1 ) httpd 設定ファイル /etc/httpd/conf/httpd.conf の編集
[root@linux ~]# vi /etc/httpd/conf/httpd.conf 

#
# Don't give away too much information about all the subcomponents
# we are running.  Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
#
# Server HTTP 応答ヘッダでOS名を表示しないようにする
ServerTokens Prod
  :
  :
#
# 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 webmaster@mountainbigroad.jp

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make 
# redirections work in a sensible way.
#
# サーバが自分自身を示すときに使うホスト名とポートを指定
ServerName mountainbigroad.jp:80
  :
  :
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

#
# 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.
#
    # SSIの許可(コマンドExec含む)、CGIの許可、シンボリックリンク許可
    Options Includes ExecCGI 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
#
    # .htaccessの許可
    AllowOverride All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>
  :
  :
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
# 414 Error(Request URI Too Large)はログに記録しない
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
# CustomLog logs/access_log common
# ログの記録内容変更(worm、Local からのアクセスはログに記録しない)
SetEnvIf Request_URI "default\.ida" no_log
SetEnvIf Request_URI "cmd\.exe" no_log
SetEnvIf Request_URI "root\.exe" no_log
SetEnvIf Request_URI "Admin\.dll" no_log
SetEnvIf Request_URI "NULL\.IDA" no_log
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(ico)|(css)$" no_log
SetEnvIf Remote_Addr 192.168. no_log
CustomLog logs/access_log combined env=!no_log
  :
  :
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
# エラーページ等でApacheのバージョンを表示しない
ServerSignature Off
  :
  :
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    # /var/www/cgi-bin/ 以下も .htaccess を許可
    #AllowOverride None
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>
  :
  :
#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
# デフォルトキャラセットを無効にする
AddDefaultCharset Off
  :
  :
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
# CGIスクリプトを実行できる様にする
AddHandler cgi-script .cgi .pl
3. CGIを実行するPerlのシンボリックリンクを貼る(FreeのCGIを使用する際の対応)
[root@linux ~]# ln -s /usr/bin/perl /usr/local/bin/perl 

[root@linux ~]# whereis perl 
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
4. Apache の起動
1 ) httpd の起動
[root@linux ~]# service httpd start 
httpdを起動中:                                             [  OK  ]
2 ) httpd の自動起動設定
[root@linux ~]# chkconfig httpd on 
[root@linux ~]# chkconfig --list httpd 
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
5. Apache の動作確認
1 ) Windowsクライアントから実施(ブラウザ)
Windowsクライアントより [http://サーバのアドレス/] でアクセスして以下の様な画面が表示されればOKです。
Welcome Apache httpd Server
2 ) テストページの削除
確認で使用したページ関連は、今後必要ないので削除します。
[root@linux ~]# rm -f /etc/httpd/conf.d/welcome.conf 
[root@linux ~]# rm -f /var/www/error/noindex.html 
6. 公開前の準備
ホームページを外部に公開するには、ルータの設定で ポート番号80番(HTTP World Wide Web) を開けてください。
また、外部よりDNS名でアクセスするには、ドメイン名の取得を行っている必要があります。