![]() |
| ◆ | 注意 |
| ここでの内容は、コンソールモード時の文字化け対策 で紹介した bterm を起動した状態での内容です。bterm を起動しない状態でも内容は同じですが一部日本語表記が文字化けする場合があります。 | |
| ◆ | Apache のインストール |
|
Fedora Core 4 のインストール時 “Webサーバ” を選択していれば Apache はインストールされています。 もし、Fedora Core 4 のインストール時 “Webサーバ” を選択していない場合は下記要領でインストールして下さい。 下記のように入力します。 |
|
|
[user@linux]$ su
← ユーザーでログインしている場合は root に移行 password : ****** ← root のパスワード入力(* は実際には表示されません) [root@linux]# yum inatall httpd ← yum inatall httpd を入力 Setting up Install Process updates-released 100% |=====================| 951 B 00:00 ↓↓ ↓↓ 途中省略 ↓↓ Total download size: 1.1 M Is this ok [y/n]: y ← y を入力 Downloading Packages: ↓↓ ↓↓ 途中省略 ↓↓ Dependency Installed: apr.i386 0:0.9.6-3.5 apr-util.i386 0:0.9.6-2 Complete! ← Complete! と表示されれば完了 [root@linux]# |
|
| 以上で完了です。 | |
| ◆ | Apache の設定 |
| 下記のように入力します。上記のように Apache の設定ファイル が表示されます。 | |
| [root@linux]# vi /etc/httpd/conf/httpd.conf | |
| 下記のように緑色の部分を黄色に変更(書き換え・削除)して下さい。赤文字は説明です。 | |
| # # Based upon the NCSA server configuration files originally by Rob McCool. # # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about # the directives. ↓↓ ↓↓ 途中省略 ↓↓ # 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 ServerTokens OS ↓ エラーページでOS名を表示しないようにする。(セキュリティー対策) ServerTokens Prod # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. ↓↓ ↓↓ 途中省略 ↓↓ # 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 ↓ 通常は変更の必要はない。ポートを指定する場合のみ変更 Listen 8888 # Dynamic Shared Object (DSO) Support ↓↓ ↓↓ 途中省略 ↓↓ # User/Group: The name (or #number) of the user/group to run httpd as. # . On SCO (ODT 3) use "User nouser" and "Group nogroup". # . On HPUX you may not be able to use shared memory as nobody, and the # suggested workaround is to create a user www and use that user. # NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET) # when the value of (unsigned)Group is above 60000; # don't use Group #-1 on these systems! # User apache ↓ Apache のユーザー権限を変更。(セキュリティー対策) User nobody Group apache ↓ Apache のグループ権限を変更。(セキュリティー対策) Group nobody ### Section 2: 'Main' server configuration ↓↓ ↓↓ 途中省略 ↓↓ # 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 root@localhost ↓ エラーページに表示される管理者のメールアドレスを指定。 ServerAdmin papa-net@papa-net.ddo.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 www.example.com:80 ↓ サーバー名を指定。(ドメイン名:ポート番号 という形で指定) ServerName papa-net.ddo.jp:80 # # UseCanonicalName: Determines how Apache constructs self-referencing # URLs and the SERVER_NAME and SERVER_PORT variables. # When set "Off", Apache will use the Hostname and Port supplied # 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 "/var/www/html" ↓ HPファイルを格納するフォルダーを指定。 DocumentRoot "/home/user/www" # # Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that # directory (and its subdirectories). ↓↓ ↓↓ 途中省略 ↓↓ # This should be changed to whatever you set DocumentRoot to. # <Directory "/var/www/html"> ↓ HPファイルを格納するフォルダーを指定。 <Directory "/home/user/www"> # # 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 ↓ index ファイルが無い場合フォルダ内が閲覧できていまうので閲覧できないようにする。(セキュリティー対策) Options 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 ↓↓ ↓↓ 途中省略 ↓↓ # # 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 index.html.var ↓ index ファイルの指定に index.htm を追加する。 DirectoryIndex index.htm index.html index.html.var # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # ↓↓ ↓↓ 途中省略 ↓↓ # # 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 # ServerSignature On ↓ エラーページで Apache のバージョンを表示しないようにする。(セキュリティー対策) ServerSignature Off # # Aliases: Add here as many aliases as you need (with no limit). The format is # Alias fakename realname ↓↓ ↓↓ 途中省略 ↓↓ # # 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/" ← CGIファイル格納フォルダを複数作る場合はコメント化 ↓ CGIファイルを格納するフォルダを指定。 ScriptAlias /cgi-bin/ "/home/user/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"> ← CGIファイル格納フォルダを複数作る場合は ↓ CGIファイルを格納するフォルダーを指定。 <Directory "/var/www/cgi-bin">〜</Directory>を追記 <Directory "/home/user/www/cgi-bin"> AllowOverride None Options None ↓ CGIファイルを実行内容の指定。 Options Includes ExecCGI FollowSymLinks ←CGI・SSI・シンボリックの許可。 Order allow,deny Allow from all </Directory> ↓↓ ↓↓ 途中省略 ↓↓ AddLanguage ca .ca ← ここに AddLanguage ja .ja を持って来る。(文字化け対策) AddLanguage cs .cz .cs AddLanguage da .dk AddLanguage de .de AddLanguage el .el AddLanguage en .en AddLanguage eo .eo AddLanguage es .es AddLanguage et .et AddLanguage fr .fr AddLanguage he .he AddLanguage hr .hr AddLanguage it .it AddLanguage ja .ja ← 一番上に持って行く。(文字化け対策) AddLanguage ko .ko AddLanguage ltz .ltz AddLanguage nl .nl AddLanguage nn .nn AddLanguage no .no AddLanguage pl .po AddLanguage pt .pt AddLanguage pt-BR .pt-br AddLanguage ru .ru AddLanguage sv .sv AddLanguage zh-CN .zh-cn AddLanguage zh-TW .zh-tw # # LanguagePriority allows you to give precedence to some languages # in case of a tie during content negotiation. # # 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 ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW ↓ ja を先頭に持って行く。(文字化け対策) LanguagePriority ja en ca cs da de el eo es et fr he hr it ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW # # ForceLanguagePriority allows you to serve a result page rather than # MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback) # [in case no accepted languages matched the available variants] # ForceLanguagePriority Prefer Fallback # # Specify a default charset for all content served; this enables # interpretation of all content as UTF-8 by default. To use the # default browser choice (ISO-8859-1), or to allow the META tags # in HTML content to override this choice, comment out this # directive: # AddDefaultCharset UTF-8 ← もしHPの文字コードが解れば記述する。(AddDefaultCharaset EUC-JP 等) ↓ デフォルト文字コードのコメント化。(文字化け対策) # AddDefaultCharset UTF-8 # # AddType allows you to add to or override the MIME configuration # file mime.types for specific file types. ↓↓ ↓↓ 途中省略 ↓↓ # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi ↓ CGIファイルを実行できるように指定。 AddHandler cgi-script .cgi .pl ←CGIスクリプトに .pl 等を追加。 # # For files that include their own HTTP headers: # #AddHandler send-as-is asis ↓↓ ↓↓ 途中省略 ↓↓ #<VirtualHost *:80> # ServerAdmin webmaster@dummy-host.example.com # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> |
|
| 次に、ドキュメントルートの所有者変更をします。下記のように入力します。 | |
| [root@linux]# chown user. /home/user/www/ ← 入力(ドキュメントルートの所有者をuserに変更) | |
| ◆ | ポートの開放 |
|
Webサーバー用のポート 80 を開放します。 下記のように入力します。 |
|
| [root@linux]# vi /etc/sysconfig/iptables ← vi /etc/sysconfig/iptables を入力(設定ファイル iptables を開く) | |
| 設定ファイル iptables が開きますので最終行に -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT を追記してポート番号 80 を開きます。 | |
|
# Firewall configuration written by system-config-securitylevel # Manual customization of this file is recommended. *filter : IMPUT ACCEPT [0:0] ↓↓ ↓↓ 途中省略 ↓↓ -A INPUT -j RH-Firewall-1-INPUT ↓↓ ↓↓ 途中省略 ↓↓ -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT ← 最終行に追記 |
|
| 設定を反映させるため iptables を再起動させます。 | |
|
[root@papa-net ~]# /etc/rc.d/init.d/iptables restart ← /etc/rc.d/init.d/iptables iptables を入力 ファイアウォールルールを適用中: [ OK ] チェインポリシーを ACCEPT に設定中filter [ OK ] iptables モジュールを取り外し中 [ OK ] iptables ファイアウォールルールを適用中: [ OK ] iptables モジュールを読み込み中ip_conntrack_netbios_ns [ OK ] |
|
| ◆ | Apache の再起動 |
| 下記のように入力します。 | |
|
[root@linux]# /etc/rc.d/init.d/httpd start
← /etc/rc.d/init.d/httpd start
を入力(apache の起動) httpd を起動中: [ OK ] [root@linux]# |
|
| 続いてPCの再起動に apache を自動的に起動するようにします。下記のように入力します。 | |
| [root@linux]# chkconfig httpd on ← chkconfig httpd on を入力(apache の自動起動) | |
| 自動起動設定の確認。下記のように入力し 、下記のように表示されればOKです。 | |
|
[root@linux]# chkconfig --list httpd
← chkconfig --list httpd
を入力(apache の自動起動確認) httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
|
| 再起動は下記のように入力します。 | |
| [root@linux]# /etc/rc.d/init.d/httpd restart | |