UJP - 技術情報

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

     

Apache 1.1.1インストール 〜for Solaris 2.5.1〜


Apache 1.1.1インストール

〜for Solaris 2.5.1〜


0.改訂履歴

  • 1997.10.31 初版
  • 1997.11.20 内容に変更のない微調整(重要な部分に色を追加した)
  • 2000.05.14 不要な情報を消した

1.はじめに

 このドキュメントでは,Solaris2.5.1にApache1.1.1をインストールする手順を示す.

2.Apacheとは?

 NCSAがNCSA httpd 1.3のパッチを作成する為に組織されたグループが,その後にWWWサーバを新たに作ってしまおうということで作りはじめたので, 語源は"a patch"なのだそうである.

 今現在,WWWサーバとしては約40%のシェアを持ち,フリーで配布され,世界で一番テストされているサーバである.

3.入手とダウンロード

 ソースコードはhttp://www.apache.org/から一番快適なFTPサーバを選択してダウンロードしてください.
 なぜapacheにするかは,http://www.apache.org/info.htmlをご覧ください.

4.アーカイブの展開

 取得したファイルはアーカイブとなっている.

root@duo# ls -la
total 596
drwxr-xr-x   2 root     other        512 Oct 30 20:35 .
drwxr-xr-x   5 root     other        512 Oct 30 20:35 ..
-rw-r--r--   1 root     other     289700 Oct 30 20:35 apache.1.1.1_tar.gz
root@duo#

  • 拡張子がgzなので,gzipで圧縮されていることが判る.よって,gzipで展開する.

root@duo# gzip -d apache.1.1.1_tar.gz
root@duo# ls -la
total 2372
drwxr-xr-x   2 root     other        512 Oct 30 20:43 .
drwxr-xr-x   5 root     other        512 Oct 30 20:35 ..
-rw-r--r--   1 root     other    1198080 Oct 30 20:35 apache.1.1.1_tar
root@duo#

  • tarファイルを展開する.

root@duo# tar xf apache.1.1.1_tar
root@duo# ls -la
total 2374
drwxr-xr-x   3 root     other        512 Oct 30 20:44 .
drwxr-xr-x   5 root     other        512 Oct 30 20:35 ..
-rw-r--r--   1 root     other    1198080 Oct 30 20:35 apache.1.1.1_tar
drwxrwxr-x   9 129      nuucp        512 Jul  9  1996 apache_1.1.1
root@duo#

  • すると,ディレクトリができ上がる. ディレクトリ内のリストを出すと,次のようになっている.

root@duo# cd apache_1.1.1
root@duo# ls -la
total 42
drwxrwxr-x   9 129      nuucp        512 Jul  9  1996 .
drwxr-xr-x   3 root     other        512 Oct 30 20:44 ..
-rw-rw-r--   1 129      nuucp       3738 Mar 13  1996 CHANGES
-rw-rw-r--   1 129      nuucp       2604 Feb 22  1996 LICENSE
-rw-rw-r--   1 129      nuucp       3059 Jul  3  1996 README
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 cgi-bin
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 conf
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 htdocs
drwxrwxr-x   2 129      nuucp       2048 Jul  9  1996 icons
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 logs
drwxrwxr-x   2 129      nuucp       2048 Jul 10  1996 src
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 support
root@duo#

5.インストールディレクトリ

 Apacheは,デフォルトで次のようなディレクトリに存在しているように作成されている.

機能 パス
サーバルート /usr/local/etc/httpd
ドキュメントルート /usr/local/etc/httpd/htdocs

 この記述は,httpd.hファイルに書かれているので,必要であればこれを変更する.

#define HTTPD_ROOT "/usr/local/etc/httpd"
#endif

/* Root of server */
#ifdef __EMX__
/* Set default for OS/2 file system */
#define DOCUMENT_LOCATION "/os2httpd/docs"
#else
#define DOCUMENT_LOCATION "/usr/local/etc/httpd/htdocs"
#endif

5.コンフィグレーション

 環境設定ファイルは,confディレクトリ以下に有る.

root@duo# cd conf
root@duo# ls -la
total 40
drwxrwxr-x   2 129      nuucp        512 Jul  9  1996 .
drwxrwxr-x   9 129      nuucp        512 Jul  9  1996 ..
-rw-rw-r--   1 129      nuucp       1671 Jul  4  1996 access.conf-dist
-rw-rw-r--   1 129      nuucp       5657 Jun  8  1996 httpd.conf-dist
-rw-rw-r--   1 129      nuucp       2405 Jun  8  1996 mime.types
-rw-rw-r--   1 129      nuucp       6914 Jun 13  1996 srm.conf-dist
root@duo#

 これらの〜-distファイルは,設定ファイルのサンプルなので,これを複写して名前を変更する.

本の名前 複写後の名前
access.conf-dist
access.conf
httpd.conf-dist
httpd.conf
srm.conf-dist
srm.conf

 とりあえずは,httpd.conf,srm.confファイルを編集する.

5.1.ポート番号(httpd.conf)

 ポート番号は,デフォルトで80番となっている. これを変更する場合には,httpd.conf-distファイル内のPort部分を編集する.

# Port: The port the standalone listens to. For ports < 1023, you will
# need httpd to be run as root initially.

Port 80

5.2.サーバルートの設定(httpd.conf)

 WWWサーバの基本となるディレクトリを設定するために,ServerRootを編集する.

# ServerRoot: The directory the server's config, error, and log files
# are kept in

ServerRoot /usr/local/etc/httpd

 このディレクトリの下に,アクセスログ,エラーログなどが格納されるようになる.

5.3.ドキュメントルートの編集(srm.conf)

 WWWサーバのドキュメントがおかれている場所を設定するために,DocumentRootを編集する.

# 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 /usr/local/etc/httpd/htdocs

5.4.サーバ名

# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e. use
# "www" instead of the host's real name).
#
# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.

#ServerName new.host.name
ServerName www.duo.co.jp

6.Makefileの作成

 srcディレクトリに移動し,Configurationファイルを変更する.

6.1.コンパイラの指定

 CCを変更する. デフォルトでは,gccになっているが,導入されているコンパイラを指定する. 今回は,富士通コンパイラのfccを使用する.

CC部分のデフォルト
# What to call the compiler:  For normal machines with ANSI compilers
# CC= cc
# For Suns or other non-ANSI platforms. Please make sure your gcc is
# 2.0 or later, as 1.40 seems to create bad code for the Sun 4.
CC= gcc

CCをfccに変更
# What to call the compiler:  For normal machines with ANSI compilers
# CC= cc
# For Suns or other non-ANSI platforms. Please make sure your gcc is
# 2.0 or later, as 1.40 seems to create bad code for the Sun 4.
CC= fcc

6.2.コンパイルオプションの設定

 Apacheは,色々なプラットホーム用に作成されている. よって,そのプラットフォーム毎にコンパイルオプションを設定する必要が有る.

 最初はコメントアウトされているので,それを取り除く.

コンパイルオプションのデフォルト
# For SunOS 4
#AUX_CFLAGS= -DSUNOS4
# For Solaris 2.
#AUX_CFLAGS= -DSOLARIS2
#AUX_LIBS= -lsocket -lnsl
# For SGI IRIX. Use the AUX_LIBS line if you're using NIS and want
# user-supported directories

コンパイルオプションのコメントをハズした
# For SunOS 4
#AUX_CFLAGS= -DSUNOS4
# For Solaris 2.
AUX_CFLAGS= -DSOLARIS2
AUX_LIBS= -lsocket -lnsl
# For SGI IRIX. Use the AUX_LIBS line if you're using NIS and want
# user-supported directories

6.3.Makefileの生成

 Configureコマンドを利用して,編集したConfigurationファイルからMakefileを生成する.

root@duo# Configure -file Configuration
Using alternate config file Configuration
root@duo# ls -lat | head
total 1940
drwxrwxr-x   2 129      nuucp       2048 Oct 30 21:00 .
-rw-r--r--   1 root     other       3508 Oct 30 21:00 Makefile
-rw-r--r--   1 root     other       1193 Oct 30 21:00 modules.c
-rw-r--r--   1 root     other       3508 Oct 30 21:00 Makefile.bak
-rw-r--r--   1 root     other       1193 Oct 30 21:00 modules.c.bak
-rw-rw-r--   1 129      nuucp      10013 Oct 30 21:00 Configuration
drwxrwxr-x   9 129      nuucp        512 Jul  9  1996 ..
-rw-rw-r--   1 129      nuucp      18745 Jul  9  1996 httpd.h
-rw-rw-r--   1 129      nuucp      32674 Jul  9  1996 mod_negotiation.c

 Makefileが作成されていることが判る.

6.4.コンパイル

 Makefileが作成されたので,それを用いてコンパイルを行なう.

root@duo# make
fcc -c -O2 -DSOLARIS2 alloc.c
fcc -c -O2 -DSOLARIS2 http_main.c
fcc -c -O2 -DSOLARIS2 http_core.c
fcc -c -O2 -DSOLARIS2 http_config.c
fcc -c -O2 -DSOLARIS2 http_request.c
fcc -c -O2 -DSOLARIS2 http_log.c
fcc -c -O2 -DSOLARIS2 http_protocol.c
fcc -c -O2 -DSOLARIS2 rfc1413.c
fcc -c -O2 -DSOLARIS2 util.c
fcc -c -O2 -DSOLARIS2 util_script.c
fcc -c -O2 -DSOLARIS2 modules.c
fcc -c -O2 -DSOLARIS2 buff.c
fcc -c -O2 -DSOLARIS2 md5c.c
fcc -c -O2 -DSOLARIS2 util_md5.c
fcc -c -O2 -DSOLARIS2 explain.c
fcc -c -O2 -DSOLARIS2  http_bprintf.c
fcc -c -O2 -DSOLARIS2 mod_mime.c
fcc -c -O2 -DSOLARIS2 mod_access.c
fcc -c -O2 -DSOLARIS2 mod_auth.c
fcc -c -O2 -DSOLARIS2 mod_negotiation.c
fcc -c -O2 -DSOLARIS2 mod_include.c
fcc -c -O2 -DSOLARIS2 mod_dir.c
fcc -c -O2 -DSOLARIS2 mod_cgi.c
fcc -c -O2 -DSOLARIS2 mod_userdir.c
fcc -c -O2 -DSOLARIS2 mod_alias.c
fcc -c -O2 -DSOLARIS2 mod_env.c
fcc -c -O2 -DSOLARIS2 mod_log_common.c
fcc -c -O2 -DSOLARIS2 mod_asis.c
fcc -c -O2 -DSOLARIS2 mod_imap.c
fcc -c -O2 -DSOLARIS2 mod_actions.c
fcc   -o httpd alloc.o http_main.o http_core.o http_config.o http_request.o  htt
p_log.o http_protocol.o rfc1413.o util.o util_script.o modules.o buff.o md5c.o u
til_md5.o explain.o http_bprintf.o mod_mime.o  mod_access.o  mod_auth.o  mod_neg
otiation.o  mod_include.o  mod_dir.o  mod_cgi.o  mod_userdir.o  mod_alias.o  mod
_env.o  mod_log_common.o  mod_asis.o  mod_imap.o  mod_actions.o  -lsocket -lnsl
root@duo#

  • コンパイルが正しく終了すると,次のようにモジュールが作成されている.

root@duo# ls -lat|head
total 3030
drwxrwxr-x   2 129      nuucp       2560 Oct 30 21:10 .
-rwxr-xr-x   1 root     other     233392 Oct 30 21:10 httpd
-rw-r--r--   1 root     other       4936 Oct 30 21:10 mod_actions.o
-rw-r--r--   1 root     other      19812 Oct 30 21:10 mod_imap.o
-rw-r--r--   1 root     other       3716 Oct 30 21:10 mod_asis.o
-rw-r--r--   1 root     other       5988 Oct 30 21:10 mod_log_common.o
-rw-r--r--   1 root     other       4964 Oct 30 21:10 mod_env.o
-rw-r--r--   1 root     other       5488 Oct 30 21:10 mod_alias.o
-rw-r--r--   1 root     other       7060 Oct 30 21:10 mod_cgi.o
root@duo#

7.WWWサーバの起動

 モジュールが作成できたら,WWWサーバを起動してみる.

 単純に実行すると,次のようなエラーが出るはずである.

root@duo# httpd
httpd: could not open document config file /usr/local/etc/httpd/conf/httpd.conf
fopen: No such file or directory
root@duo#

 これは,モジュールが埋込で,環境設定ファイルを/usr/local/etc/httpd/conf/httpd.confとしているからである. よって,先ほど編集したhttpd.confファイルを指定するようにして起動させればよい.

root@duo# httpd

8.アクセステスト

 適当なWWWブラウザで接続してみる.成功すれば,次のような画面が表示される.

It Worked!

If you can see this, then your Apache installation was successful. You may now add content to this directory and replace this page.

You are free to use the image below on an Apache-powered web server. Thanks for using Apache!

9.WWWサーバが起動しないときなどのトレース

 サーバが起動しようとしたときにエラーが出た場合には,エラーログが書かれている.

9.1.サーバが起動しないとき

 httpdを起動しても,一見正常に起動したように見えて,psコマンドでプロセスを参照すると,稼働していない場合が有る.

 その時はlogsフォルダ以下のerror_logファイルを参照する. すると次のように記述されているかもしれない.

[Thu Oct 30 22:24:53 1997] setgid: Invalid argument
[Thu Oct 30 22:24:53 1997] - unable to set group id

 これは,httpdプロセスのユーザがrootである場合に起こる. root以外のユーザで稼働させることを薦める.

9.2.httpdコマンド実行時に,エラーとなる

 root以外のユーザで実行する場合に,次のように権限無しエラーが表示される事が有る.

$ httpd
$ bind: Permission denied
httpd: could not bind to port 80

$

 これはポート番号80番を使用する権利が無いと言うことになる. このエラーを回避するには,次の2通りの方法がある.

  • ポート番号を80番以外にする
  • 権限を割り当てる


広告スペース
Google