CentOS5で新サーバ構築/(3)WWWサーバのチューニング

Last-modified: 2008-06-30 (月) 16:13:08 (5798d)

WWWサーバのチューニング

WWWサーバの立上げに続いて、いくつかのチューニングを行う。

文字コードの変換

  • httpd.confの設定を変更して、ブラウザで見たときの文字化け表示は一応解消しているが、サーバ上はそうはいかない。トップページ関係のファイルを編集する場合は、半角英数字以外は化けてしまう。
  • これは、何かと不都合なので、トップページ関係の全ファイルの文字コードを変換しておく。対象ファイルは、以下のとおりである。
    index.php      トップページ(常に更新表示されるようphp化してある)
    kurari_ikou.html  移行について
    member.html     初期登録メンバー
    change.html     変更履歴
    kurari_sys.html   システム構成
    howto.html     使用方法
    pastlog.html    過去ログ、年表
  • 使うツールは nkf である。UTF-8への変更パラメータは -w。
    • catで表示して、nkfへパイプして、ファイル書き出し
    • vi でファイル編集 charsetを"utf8"に修正
    • ファイル名を元に戻す(上書き保存)
      [root@kuraric5 html]# cat index.hp | nkf -w > index.php.utf
      
      [root@kuraric5 html]# vi index.php.utf
      ---
      <META http-equiv=Content-Type content="text/html; charset=euc-J">
        ↓
      <META http-equiv=Content-Type content="text/html; charset=utf8">
      
      [root@kuraric5 html]# mv index.php.utf index.php
      index.html' を上書きしてもよろしいですか(yes/no)? y

ユーザ認証の変更

  • アクセス試験で ページ表示自体はすべて問題ないが、アクセス制限がうまくいかない。
  • アクセス制限をかけているのは、html関係では、wiki、山記録、過去ログ+15年史である。
  • 認証方式の変更を行う。「.htaccess」ファイルではなく、「httpd.conf」に書き込む形に変更する。
    ①httpd.confの修正を編集し、追記した
    [root@kuraric5 html]# cd /etc/httpd/conf
    [root@kuraric5 conf]# vi httpd.conf
    
    # --- control access changed --2007/8/05 ---------------------------
     DocumentRoot "/var/www/html"
     <Directory "/var/www/html">
     ・・・・・
     </Directory>
    【この後に追加する】 
    
    <Directory "/var/www/html/wiki">
        AllowOverride None
        Order allow,deny
        Allow from all
        AuthType Basic
        Authname "Kurari-net_BBS"
        AuthUserFile /var/www/.htpasswd
        AuthGroupFile   /dev/null
        require valid-user
    </Directory>
    
    <Directory "/var/www/html/past">
    【同様に(略)】
    
    <Directory "/var/www/html/members">
    【同様に(略)】
    
    <Directory "/var/www/html/bbs16">
    【同様に(略)】
    # --- control access changed -----------------------------------------

②各ディレクトリに残っていた「.htaccess」ファイルを削除する

[root@kuraic4 html]# cd /var/www/html/wiki
[root@kuraic4 wiki]# rm .htaccess
rm: remove シンボリックリンク `.htaccess'? y
  • 同様に、他のDIR配下でも削除する

CGI関係の認証設定

  • 掲示板とイメージ掲示板についてもアクセス制限を行うため、confを編集する。
    [root@kuraic4 bbs]# vi /etc/httpd/conf/httpd.conf
    ---------
    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.
    #
    
    #--- 2007/8/05Access control change ------------------------
    <Directory "/var/www/cgi-bin">
    #   AllowOverride None
        AllowOverride All
    #   Options None
        Options All
        Order allow,deny
        Allow from all
    </Directory>
    #--------------------------------------------------------------
  • httpd再起動して有効化
    [root@kuraric5 conf]# /etc/rc.d/init.d/httpd restart
    httpd を停止中:                                            [  OK  ]
    httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                              [  OK  ]
  • 動作確認する。アクセス制限の確認はブラウザ再起動が必要なので、簡単のため普段使っていないIE使うが、それぞれ、ユーザ認証は問題なし!

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   リンク元