434 views


■概要

Webサーバー(Apache)はInternet Explorer等のブラウザから自宅サーバーのWebページをみれるようにするためのサーバーです。ここでは、一般的なWebサーバーと同様に以下のことができるようにします。

■Webサーバーインストール

[root@ufuso ~]# yum -y install httpd ← httpdをインストール
Setting up Install Process
Package httpd-2.2.15-9.sl6.3.x86_64 already installed and latest version
Nothing to do ← すでにインストール済み

■phpのインストール(phpで作成されたWordPressを自サイトで使用しているため)

[root@ufuso ~]# yum -y install php php-mbstring php-pear ← phpのインストール
Installed:
  php.x86_64 0:5.3.2-6.el6_0.1       php-mbstring.x86_64 0:5.3.2-6.el6_0.1
  php-pear.noarch 1:1.9.0-2.el6     

Dependency Installed:
  php-cli.x86_64 0:5.3.2-6.el6_0.1      php-common.x86_64 0:5.3.2-6.el6_0.1     

Complete!

[root@ufuso ~]# /etc/rc.d/init.d/httpd restart ← httpdの再起動
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

■Webサーバー設定

(1)Webサーバー設定

[root@ufuso ~]# vi /etc/httpd/conf/httpd.conf ← httpd設定ファイル編集
ServerTokens OS
↓
ServerTokens Prod ← エラーページ等でOS名を表示しないようにする

KeepAlive Off
↓
KeepAlive  On ← 

ServerAdmin root@localhost
↓
ServerAdmin webmaster@ufuso.dip.jp
 ← エラーページ等に表示される管理者メールアドレスを指定

#ServerName www.example.com:80
↓
ServerName ufuso.dip.jp:80 ← サーバー名を指定

<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.
#
    Options Indexes FollowSymLinks
  ↓
    Options Includes ExecCGI FollowSymLinks ← CGI,SSIの許可

#
# 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
  ↓
    AllowOverride All ← .htaccessの許可

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t "%!414r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
 ← 長すぎるURI(414エラー)はログに記録しない

#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
SetEnvIf Request_URI "default.ida" no_log ← wormからのアクセスをログに記録しない
SetEnvIf Request_URI "cmd.exe" no_log ← wormからのアクセスをログに記録しない
SetEnvIf Request_URI "root.exe" no_log ← wormからのアクセスをログに記録しない
SetEnvIf Request_URI "Admin.dll" no_log ← wormからのアクセスをログに記録しない
SetEnvIf Request_URI "NULL.IDA" no_log ← wormからのアクセスをログに記録しない
SetEnvIf Remote_Addr 192.168.1 no_log ← 内部からのアクセスをログに記録しない
SetEnvIf Remote_Addr 127.0.0.1 no_log ← 自ホストからのアクセスをログに記録しない
CustomLog logs/access_log combined env=!no_log ← 上記以外のアクセスをログに記録する

ServerSignature On
↓
ServerSignature Off ← エラーページ等でApacheのバージョンを表示しないようにする

<Directory "/var/www/icons">
    Options Indexes MultiViews
    ↓
    Options MultiViews ← iconsディレクトリのファイル一覧を表示しないようにする
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8 ← コメントアウト

#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl ← #を外し、CGIスクリプトに.plを追加

■Perlコマンドへ/usr/local/bin/perlでもアクセスできるようにする

[root@ufuso ~]# ln -s /usr/bin/perl /usr/local/bin/perl
 ← /usr/local/bin/perlから/usr/bin/perlへリンクをはる

[root@ufuso ~]# whereis perl ← Perlのパスを確認
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
 ← Perlのパスに/usr/local/bin/perlが表示されることを確認

■ドキュメントルート所有者変更

ここでは、例としてドキュメントルート所有者をufusoに変更する。

[root@ufuso ~]# chown ufuso. /var/www/html/ ← ドキュメントルート所有者変更

■Webサーバー起動

(1)Webサーバー起動

[root@ufuso ~]# /etc/rc.d/init.d/httpd start ← httpd起動
httpd を起動中:                                            [  OK  ]

[root@centos ~]# chkconfig httpd on ← httpd自動起動設定

[root@ufuso ~]# chkconfig --list httpd ← httpd自動起動設定確認
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
 ← ランレベル2〜5のonを確認

(2)ポート80番のOPEN

ルーター側の設定でポート80番をOPENする。

※ルーターの設定は各ルーターのマニュアルまたはメーカー別ルーターポート開放手順を参照

ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:ufuso.dip.jp)、「port番号」に80と入力して「ポートチェック」ボタン押下し、「ホスト=ufuso.dip.jp ポート=80 にアクセスできました。」と表示されることを確認。

(3)外部からのWebサーバーアクセス確認

外部からWebサーバーにアクセスできるか確認する。

[root@ufuso ~]#  echo test >> /var/www/html/index.html ← テストページ作成

以下の「URL」欄にホスト名(例:ufuso.dip.jp)を入力してTest itボタンを押下すると、自サイトがインターネット上で公開されているか確認できます。

Free Website Test tools by WebSitePulse

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください