WindowsでApache![]()
このページは、超初心者の私が、勉強がてら自宅パソコンにApacheをインストールし色々手を加えていくところを記録したものです。(決して完全なマニュアルではありません)
間違いあれば、是非メールで教えて下さい。
| /Apache | Server Root(httpd.confにて設定) | URL上のディレクトリ(URI) | |
| Apache.exe | 本体プログラム | ||
| / cgi-bin | デフォルトではhttpd.conf内でScriptAlias指令によって「/cgi-bin/」に設定 | /cgi-bin/ | |
| / conf | httpd.confやmime.types等の設定ファイルを保存 | ||
| / bin | htpasswd.exe等のツールを保存 | ||
| / htdocs | デフォルトではhttpd.conf内でDocument root「/」に設定 | / | |
| / icons | デフォルトではhttpd.conf内でAlias指令によって「/icons/」に設定 | /icnos/ | |
| / include | なんでしょうね? | ||
| / lib | なんでしょうね? | ||
| / libexec | なんでしょうね? | ||
| / logs | Log Fileの保存先(httpd.conf内で設定) | ||
| / modules | モジュールを保持 | ||
| / proxy | なんでしょうね? | ||
デフォルトでは、ドキュメントルートが「/htdocs」に設定されているので、ここにホームページの本体を置くことになります。CGIプログラムは、「/cgi-bin」ディレクトリに置くことで、"http://hostname/cgi-bin/"で参照できます。
アクセス制限はサーバー全体を対象とするならhttpd.conf内に、ディレクトリ毎の設定なら.htaccessファイル内におおむね次のような記述をすれば良い。httpd.confファイルはサーバー管理者しか編集できません。各ユーザーは.htaccessをディレクトリに置くことで、そのディレクトリ(含サブディレクトリ)の設定を行います。
<Directory c:/httpd/apache/htdocs> AuthUserfile c:\password AuthName "パスワードを入力して下さい" AuthType Basic require valid-user </Directory> |
.htaccessの書き方やディレクティブの詳細はミケネコの.htaccessリファレンスやApache付属のドキュメント参照。
AuthUserfile c:\password AuthName "パスワードを入力して下さい" AuthType Basic require valid-user |
C:\httpd\Apache\bin > htpasswd
Usage:
htpasswd [-cmdps] passwordfile username
htpasswd -b[cmdps] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
On Windows, TPF and NetWare systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
C:\httpd\Apache\bin >
|
htpasswd.exeの使い方。 |
C:\httpd\Apache\bin > htpasswd -c c:\password hiroshi Automatically using MD5 format on Windows. New password: ***** Re-type new password: ***** Adding password for user hiroshi C:\httpd\Apache\bin > |
初めてパスワードファイルを作成します。「-c」オプションを使います。 |
C:\httpd\Apache\bin > htpasswd c:\password aoki Automatically using MD5 format on Windows. New password: **** Re-type new password: **** Adding password for user aoki C:\httpd\Apache\bin > |
既にあるパスワードファイルにユーザーを追加します。 |