1.Apacheのインストール作業
# rpm -ihv httpd-2.0.40-21.i386.rpm 警告: httpd-2.0.40-21.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e Preparing... ########################################### [100%] 1:httpd ########################################### [100%] # rpm -ihv indexhtml-9-3.noarch.rpm 警告: indexhtml-9-3.noarch.rpm: V3 DSA signature: NOKEY, key ID db42a60e Preparing... ########################################### [100%] 1:indexhtml ########################################### [100%] |
インストール作業 |
# gethostip kkataru02.kkataru.mine.nu kkataru02.kkataru.mine.nu 127.0.0.1 (OK) kkataru02.kkataru.mine.nu Unknown host (NG) (NGの場合) /etc/hostsにホスト名及びIPを記入する。 192.168.0.2 kkataru02.kkataru.mine.nu |
ホストの名前解決できる状況 確認 |
# /etc/rc.d/init.d/httpd start httpdを起動中: [ OK ] ![]() |
起動確認 |
# chkconfig httpd on | 自動起動 |
2.Apacheの設定
apacheのメイン設定ファイルは/etc/httpd/donf/httpd.conf
# vi /etc/httpd/conf/httpd.conf | 設定ファイル |
# # 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 root@lkkataru.mine.nu |
管理者のアドレス |
# 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 new.host.name:80 ServerName kkataru02.kkataru.mine.nu:80 |
サーバ名 |
# /etc/rc.d/init.d/httpd reload httpdを再読み込み中: [ OK ] |
再起動 |
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # # 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 この箇所を変更すれば可能です。 |
TOPページに表示される ファイルを変更する場合 |
# # 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" DocumentRoot "/home/ataru/htdocsl" |
ドキュメントルートの変更 |
# Alias for Alias Alias /ataru/ "/home/ataru/alias/" |
Alias設定(末行にて作成) |
# # Specify a default charset for all pages sent out. This is # always a good idea and opens the door for future internationalisation # of your web site, should you ever want it. Specifying it as # a default does little harm; as the standard dictates that a page # is in iso-8859-1 (latin1) unless specified otherwise i.e. you # are merely stating the obvious. There are also some security # reasons in browsers, related to javascript and URL parsing # which encourage you to always set a default char set. # #AddDefaultCharset ISO-8859-1 AddDefaultCharset none |
デフォルトキャラクタセットの変更 *今までのapahe1.3ではこの様な設定は なかったよ? apache2では、デフォルトキャラクタセットがISO-8859-1 というものに設定されているので、日本語を取り扱う場合、この設定を 変更しないと文字化けが発生します。 |
# Redirect Redirect /kensaku.html http://kkataru.mine.nu |
アクセスを他のサイトに転送する。 |
# Access Control <Directory "/home/ataru/htdocs"> Allow from 192.168.0.0/255.255.255.0 Deny from all Order Deny,allow </Direvtory> |
Allow from アクセス許可リスト Deny from アクセス拒否リスト Order 評価順 (Deny,Allow:リストの後ろに記載したものが優先) |
3.ユーザ認証(ベーシック認証)
# cd /etc/httpd/conf # htpasswd -c .htpasswd ataru New password:(パスワード) Re-type new password:(パスワード) Adding password for user ataru # ls -la 合計 64 drwxr-xr-x 2 root root 4096 7月 25 16:00 . drwxr-xr-x 4 root root 4096 7月 23 14:21 .. -rw------- 1 root root 20 7月 25 16:00 .htpasswd(確認) -rw-r--r-- 1 root root 35339 7月 25 15:54 httpd.conf -rw-r--r-- 1 root root 12959 2月 25 19:07 magic # chown apache:apache .htpasswd # ls -la 合計 64 drwxr-xr-x 2 root root 4096 7月 25 16:00 . drwxr-xr-x 4 root root 4096 7月 23 14:21 .. -rw------- 1 apache apache 20 7月 25 16:00 .htpasswd(確認) -rw-r--r-- 1 root root 35339 7月 25 15:54 httpd.conf -rw-r--r-- 1 root root 12959 2月 25 19:07 magic |
ユーザ認証 .htpasswdの作成 |
# vi /etc/httpd/conf/httpd.conf #Access Control <Directory "/home/ataru/htdocs/user"> Allow from 192.168.0.0/255.255.255.0 Deny from all Order Deny,allow AuthType Basic AuthName "This page is menber only" AuthUserFile "conf/.htpasswd" Require valid-user </Directory> # /etc/rc.d/init.d/httpd reload httpdを再読み込み中: [ OK ] |
httpd.confの設定 |
![]() |
サーバのページにて 認証を確認する。 |
4.WebDAVを利用してファイル管理する。
WebDAVとは?
WebDAVシステムを構築するためのApacheの設定
# ls -la drwxrwxr-x 2 ataru ataru 4096 7月 25 16:43 ataru02 |
ataru02フォルダーを作成します。 |
# chown apache:apache ataru02 # ls -la drwxrwxr-x 2 apache apache 4096 7月 25 16:43 ataru02 |
# vi /etc/httpd/conf/httpd.conf # Use DAV <Directory "/home/ataru/htdocs/ataru02"> Allow from 192.168.58.0/255.255.255.0 Deny from all Order Deny,allow DAV on </Directory> |
httpd.confの設定 末尾に記載 |
# /etc/rc.d/init.d/httpd reload httpdを再読み込み中: [ OK ] |
再起動 |
クライアントの設定(windows2000の場合)
設定したIPアドレスを入力(例)http://192.168.0.2/ataru02/