1 views
実現する機能
Webサーバー(Apache)はInternet Explorer等のブラウザから自宅サーバーのWebページをみれるようにするためのサーバーです。
Webサーバーの導入手順
(1)Webサーバーインストール
[root@ufuso ~]# yum -y install httpd ← httpdをインストール Loaded plugins: priorities, refresh-packagekit, security Setting up Install Process Package httpd-2.2.15-15.el6.centos.1.x86_64 already installed and latest version Nothing to do ← すでにインストール済み |
(2)phpのインストール(phpで作成されたWordPressを自サイトで使用しているため)
[root@ufuso ~]# yum -y install php php-mbstring php-pear ← phpのインストール Installed: php.x86_64 0:5.3.3-14.el6_3 php-mbstring.x86_64 0:5.3.3-14.el6_3 php-pear.noarch 1:1.9.4-4.el6 Dependency Installed: php-cli.x86_64 0:5.3.3-14.el6_3 php-common.x86_64 0:5.3.3-14.el6_3 Complete! |
(3)Webサーバー設定
[root@ufuso ~]# vi /etc/httpd/conf/httpd.conf ← httpd設定ファイル編集 ServerTokens Prod ← OSをProdに変えてエラーページ等でOS名を表示しないようにする KeepAlive On ← OffをOnに変えて接続が切れていないか定期的にチェックする ServerAdmin webmaster@ufuso.dip.jp ← エラーページ等に表示される管理者メールアドレスを指定 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 Includes ExecCGI FollowSymLinks ← Indexesを削除してファイルの一覧表示を防ぎ、 Includes ExecCGIを追記して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 All ← Noneを 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 Off ← OnをOffに変更してエラーページ等でApacheのバージョンを表示しないようにする <Directory "/var/www/icons"> Options MultiViews ← Indexes、FollowSymLinksを削除して、 iconsディレクトリのファイル一覧を表示しないようにする AllowOverride None Order allow,deny Allow from all </Directory> #AddDefaultCharset UTF-8 ← 行頭に#を付けて、無効にする AddHandler cgi-script .cgi .pl ← 行頭の#を削除して有効にし、CGIスクリプトに.plを追加 |
(4)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が表示されることを確認 |
(5)ドキュメントルート所有者変更
ここでは、例としてドキュメントルート所有者をufusoに変更する。
[root@ufuso ~]# chown ufuso. /var/www/html/ ← ドキュメントルート所有者変更 |
(6)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を確認 |
(7)ポート80番のOPEN
ルーター側の設定でポート80番をOPENする。
※ルーターの設定は各ルーターのマニュアルまたはメーカー別ルーターポート開放手順を参照
ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:ufuso.dip.jp)、「port番号」に80と入力して「ポートチェック」ボタン押下し、「ホスト=ufuso.dip.jp ポート=80 にアクセスできました。」と表示されることを確認。
(8)外部からのWebサーバーアクセス確認
外部からWebサーバーにアクセスできるか確認する。
[root@ufuso ~]# echo test >> /var/www/html/index.html ← テストページ作成 |
(9)firefox等のブラウザの赤枠1にサイトのURLを入力して、赤枠2の「test」が表示されればOK。
[root@ufuso ~]# rm -f /var/www/html/index.html ← テストページの削除 |
コメントを残す