まとまりのないブログ

something which something is something

玄箱のdebianにソフトウェアをインストール

サーバ用の各種ソフトウェアをインストール

  • wgetをインストール
  • rpmをインストール
  • apacheをインストール
  • mysqlをインストール
  • php5をインストール
  • Java SDKのインストール
  • Tomcatをインストール

wgetをインストール

KURO-BOX:/# apt-get install wget
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  wget
0 upgraded, 1 newly installed, 0 to remove and 31 not upgraded.
Need to get 616kB of archives.
After unpacking 2081kB of additional disk space will be used.
Get:1 ftp://ftp.dti.ad.jp stable/main wget 1.10.2-2 [616kB]
Fetched 616kB in 2s (260kB/s)
Selecting previously deselected package wget.
(Reading database ... 10569 files and directories currently installed.)
Unpacking wget (from .../wget_1.10.2-2_powerpc.deb) ...
Setting up wget (1.10.2-2) ...

rpmをインストール

KURO-BOX:/usr/local/src# apt-get install rpm
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  libbeecrypt6 libneon25 librpm4
Suggested packages:
  alien
The following NEW packages will be installed:
  libbeecrypt6 libneon25 librpm4 rpm
0 upgraded, 4 newly installed, 0 to remove and 30 not upgraded.
Need to get 2071kB of archives.
After unpacking 6492kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 ftp://ftp.dti.ad.jp stable/main libbeecrypt6 4.1.2-6 [117kB]
Get:2 ftp://ftp.dti.ad.jp stable/main libneon25 0.25.5.dfsg-6 [103kB]
Get:3 ftp://ftp.dti.ad.jp stable/main librpm4 4.4.1-13 [1000kB]
Get:4 ftp://ftp.dti.ad.jp stable/main rpm 4.4.1-13 [851kB]
Fetched 2071kB in 7s (292kB/s)
Selecting previously deselected package libbeecrypt6.
(Reading database ... 12440 files and directories currently installed.)
Unpacking libbeecrypt6 (from .../libbeecrypt6_4.1.2-6_powerpc.deb) ...
Selecting previously deselected package libneon25.
Unpacking libneon25 (from .../libneon25_0.25.5.dfsg-6_powerpc.deb) ...
Selecting previously deselected package librpm4.
Unpacking librpm4 (from .../librpm4_4.4.1-13_powerpc.deb) ...
Selecting previously deselected package rpm.
Unpacking rpm (from .../rpm_4.4.1-13_powerpc.deb) ...
Setting up libbeecrypt6 (4.1.2-6) ...

Setting up libneon25 (0.25.5.dfsg-6) ...

Setting up librpm4 (4.4.1-13) ...

Setting up rpm (4.4.1-13) ...

apacheをインストール

apache2をインストール

KURO-BOX:/# apt-get install apache2
(省略)

設定ファイルを修正。とりあえずサーバの公開ディレクトリのみを変更にすることにした。初期設定では/var/www/がウェブページの公開ディレクトリの場所となっている。そこを変更。この設定ファイルは後で必要に応じて変更する。

KURO-BOX:/# vi /etc/apache2/sites-available/default
NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/cdn/nakahira/htdoc/
         # /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/cdn/nakahira/htdoc/>
         # /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
               # RedirectMatch ^/$ /apache2-default/
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

apache2の再起動。

KURO-BOX:/# /etc/init.d/apache2 restart
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
.

なにやらservernameがcould notなんとかと出ているが、とりあえず保留。

mysqlをインストール

apt-get installでmysqlをインストール。apt-get install mysqlで何度やってもインストールできず、またかと思いながら情報を調べてみると、apt-get install mysql-serverという風に入力しなければならない模様。・・・もしかして、vinelinuxをインストールしたときにこrをやっていたら正常にインストールできたのではないかと思ったけれど、気にしないでおくとにする。

KURO-BOX:/# aptitude install mysql-server
Reading Package Lists... Done
Building Dependency Tree
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following NEW packages will be automatically installed:
  gcc-4.1-base libdbd-mysql-perl libdbi-perl libnet-daemon-perl
  libplrpc-perl libstdc++6 mysql-client-5.0 mysql-server-5.0
The following packages have been kept back:
  adduser apt apt-utils aptitude bash cron debianutils dpkg dselect exim
  ftp groff-base initscripts iptables libblkid1 libldap2 libpam-modules
  libsasl2 logrotate nano netbase netkit-ping passwd pciutils sysvinit
  tasksel telnet telnetd util-linux whiptail
The following NEW packages will be installed:
  gcc-4.1-base libdbd-mysql-perl libdbi-perl libnet-daemon-perl
  libplrpc-perl libstdc++6 mysql-client-5.0 mysql-server mysql-server-5.0
The following packages will be upgraded:
  libgcc1
1 packages upgraded, 9 newly installed, 0 to remove and 30 not upgraded.
Need to get 35.2MB of archives. After unpacking 92.5MB will be used.
Do you want to continue? [Y/n/?] n
Abort.
KURO-BOX:/# apt-get install mysql-server
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  gcc-4.1-base libdbd-mysql-perl libdbi-perl libgcc1 libnet-daemon-perl libplrpc-perl
  libstdc++6 mysql-client-5.0 mysql-server-5.0
(省略)


Selecting previously deselected package libnet-daemon-perl.
(Reading database ... 10618 files and directories currently installed.)
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.38-1.1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2017-1.1_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.53-1etch1_powerpc.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_3.0008-1_powerpc.deb) ...
Selecting previously deselected package gcc-4.1-base.
Unpacking gcc-4.1-base (from .../gcc-4.1-base_4.1.1-21_powerpc.deb) ...
Preparing to replace libgcc1 1:3.4.3-13 (using .../libgcc1_1%3a4.1.1-21_powerpc.deb) ...
Unpacking replacement libgcc1 ...
Setting up gcc-4.1-base (4.1.1-21) ...

Setting up libgcc1 (4.1.1-21) ...

Selecting previously deselected package libstdc++6.
(Reading database ... 10769 files and directories currently installed.)
Unpacking libstdc++6 (from .../libstdc++6_4.1.1-21_powerpc.deb) ...
Selecting previously deselected package mysql-client-5.0.
Unpacking mysql-client-5.0 (from .../mysql-client-5.0_5.0.32-7etch5_powerpc.deb) ...
Selecting previously deselected package mysql-server-5.0.
Unpacking mysql-server-5.0 (from .../mysql-server-5.0_5.0.32-7etch5_powerpc.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.0.32-7etch5_all.deb) ...
Setting up libnet-daemon-perl (0.38-1.1) ...
Setting up libplrpc-perl (0.2017-1.1) ...
Setting up libdbi-perl (1.53-1etch1) ...
Setting up libdbd-mysql-perl (3.0008-1) ...
Setting up libstdc++6 (4.1.1-21) ...

Setting up mysql-client-5.0 (5.0.32-7etch5) ...
Setting up mysql-server-5.0 (5.0.32-7etch5) ...
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . ..
Checking for corrupt, not cleanly closed and upgrade needing tables..

Setting up mysql-server (5.0.32-7etch5) ...

インストールが完了したらmysqlが立ち上がった状態になっているので早速ログインしてみる。

KURO-BOX:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 10
Server version: 5.0.32-Debian_7etch5-log Debian etch distribution

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql>
mysql> exit;
Bye

問題無い模様。

php5をインストール

KURO-BOX:/# apt-get install php5
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  apache2-mpm-prefork libapache2-mod-php5 libbz2-1.0 libxml2 php5-common
Suggested packages:
  php-pear
Recommended packages:
  xml-core
The following packages will be REMOVED:
  apache2-mpm-worker
The following NEW packages will be installed:
  apache2-mpm-prefork libapache2-mod-php5 libbz2-1.0 libxml2 php5 php5-common
0 upgraded, 6 newly installed, 1 to remove and 30 not upgraded.
Need to get 3988kB of archives.
After unpacking 8495kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 ftp://ftp.dti.ad.jp stable/main libbz2-1.0 1.0.3-6 [45.7kB]
Get:2 http://security.debian.org stable/updates/main libxml2 2.6.27.dfsg-2 [779kB]
Get:3 ftp://ftp.dti.ad.jp stable/main apache2-mpm-prefork 2.2.3-4+etch4 [427kB]
Get:4 http://security.debian.org stable/updates/main php5-common 5.2.0-8+etch11 [219kB]
Get:5 http://security.debian.org stable/updates/main libapache2-mod-php5 5.2.0-8+etch11 [2516kB]
Get:6 http://security.debian.org stable/updates/main php5 5.2.0-8+etch11 [1046B]
Fetched 3988kB in 22s (179kB/s)
dpkg: apache2-mpm-worker: dependency problems, but removing anyway as you request:
 apache2 depends on apache2-mpm-worker (>= 2.2.3-4+etch4) | apache2-mpm-prefork (>= 2.2.3-4+etch4) | apache2-mpm-event (>= 2.2.3-4+etch4); however:
  Package apache2-mpm-worker is to be removed.
  Package apache2-mpm-prefork is not installed.
  Package apache2-mpm-event is not installed.
(Reading database ... 12378 files and directories currently installed.)
Removing apache2-mpm-worker ...
Stopping web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
.
Selecting previously deselected package libbz2-1.0.
(Reading database ... 12372 files and directories currently installed.)
Unpacking libbz2-1.0 (from .../libbz2-1.0_1.0.3-6_powerpc.deb) ...
Selecting previously deselected package apache2-mpm-prefork.
Unpacking apache2-mpm-prefork (from .../apache2-mpm-prefork_2.2.3-4+etch4_powerpc.deb) ...
Selecting previously deselected package libxml2.
Unpacking libxml2 (from .../libxml2_2.6.27.dfsg-2_powerpc.deb) ...
Selecting previously deselected package php5-common.
Unpacking php5-common (from .../php5-common_5.2.0-8+etch11_powerpc.deb) ...
Selecting previously deselected package libapache2-mod-php5.
Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.2.0-8+etch11_powerpc.deb) ...
Selecting previously deselected package php5.
Unpacking php5 (from .../php5_5.2.0-8+etch11_all.deb) ...
Setting up libbz2-1.0 (1.0.3-6) ...

Setting up apache2-mpm-prefork (2.2.3-4+etch4) ...
Starting web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
.

Setting up libxml2 (2.6.27.dfsg-2) ...

Setting up php5-common (5.2.0-8+etch11) ...
Setting up libapache2-mod-php5 (5.2.0-8+etch11) ...

Creating config file /etc/php5/apache2/php.ini with new version
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.11.10 for ServerName
.

Setting up php5 (5.2.0-8+etch11) ...

Java SDKのインストール

java-sdk-rpm.png玄箱のcpuはpowerpcというチップセットを使っている。java SDKもそれに合わせたものをインストールしなければならないけれど、公式サイトにはppc向けのjavaSDKが公開されていない。ppc用のjava SDKは亜ibmのサイトからダウンロードすることができる模様。ダウンロードするにはユーザ登録が必須。そしてダウンロード選択画面が表示されるのだけれど、どれを選択すればよいか迷った。

 	IBM SDK for 32-bit iSeries/pSeries
Version  142 SR9

Languages:
English International

というやつを選択してcontinueをクリックした。

java-sdk-rpm-ppc.pngIBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc.rpm をダウンロードすることにした。SDKとJava Runtime Environmentの選択ができるようになっている。開発環境を玄箱を構築するのではなく、実行環境を構築するのが目的なのだけれど、SDKをインストールする必要があるだろうか・・・。SDKはJava Runtime Environmentを含んでいるので、なんだかすっきりしないけれど、とりあえずSDKのほうをインストールしておくことにする。

rpm版のjavaSDKをインストールしようとしたら下記のエラーが出た。

KURO-BOX:/usr/local/src# rpm -ivh IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc.rpm
error: Failed dependencies:
        glibc >= 2.2 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        /bin/sh is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        ld.so.1 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libICE.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libSM.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libX11.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXext.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXi.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXt.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXtst.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libdl.so.2 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libnsl.so.1 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libpthread.so.0 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXmu.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libXp.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libgcc_s.so.1 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libm.so.6 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        librt.so.1 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libstdc++.so.5 is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.0) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.1) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.1.1) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.1.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.1.3) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libc.so.6(GLIBC_2.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libdl.so.2(GLIBC_2.0) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libdl.so.2(GLIBC_2.1) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libm.so.6(GLIBC_2.0) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libm.so.6(GLIBC_2.1) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libm.so.6(GLIBC_2.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libpthread.so.0(GLIBC_2.0) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libpthread.so.0(GLIBC_2.1) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libpthread.so.0(GLIBC_2.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        librt.so.1(GLIBC_2.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libstdc++.so.5(CXXABI_1.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
        libstdc++.so.5(GLIBCPP_3.2) is needed by IBMJava2-142-ppc32-SDK-1.4.2-9.0.ppc
KURO-BOX:/usr/local/src#

仕方がないのでrpm版では無い方で再挑戦。

KURO-BOX:/usr/local/src# tar xvfz IBMJava2-SDK-1.4.2-9.0.ppc.tgz
IBMJava2-ppc-142/
IBMJava2-ppc-142/bin/
IBMJava2-ppc-142/bin/jar
IBMJava2-ppc-142/bin/jdb
IBMJava2-ppc-142/bin/idlj
IBMJava2-ppc-142/bin/java
IBMJava2-ppc-142/bin/rmic
IBMJava2-ppc-142/bin/rmid
IBMJava2-ppc-142/bin/serialver
IBMJava2-ppc-142/bin/extcheck
IBMJava2-ppc-142/bin/keytool
IBMJava2-ppc-142/bin/javac
IBMJava2-ppc-142/bin/javah
IBMJava2-ppc-142/bin/javap
IBMJava2-ppc-142/bin/javaw
IBMJava2-ppc-142/bin/native2ascii
IBMJava2-ppc-142/bin/appletviewer
IBMJava2-ppc-142/bin/java-rmi.cgi
IBMJava2-ppc-142/bin/tnameserv
IBMJava2-ppc-142/bin/jarsigner
IBMJava2-ppc-142/bin/utetcf
IBMJava2-ppc-142/bin/javadoc
IBMJava2-ppc-142/bin/rmiregistry
IBMJava2-ppc-142/bin/policytool
IBMJava2-ppc-142/bin/jformat
IBMJava2-ppc-142/jre/
IBMJava2-ppc-142/jre/bin/
IBMJava2-ppc-142/jre/bin/j9vm/
IBMJava2-ppc-142/jre/bin/j9vm/libjvm.so
tar: Skipping to next header
 incomplete literal tree

gzip: stdin: invalid compressed data--format violated
tar: Child returned status 1
tar: Error exit delayed from previous errors
KURO-BOX:/usr/local/src# ls -l
total 64996
-rw-r--r-- 1 nakahira staff 66478415 Jun 10 00:18 IBMJava2-SDK-1.4.2-9.0.ppc.tgz
drwxr-xr-x 4 root     root      4096 Jul  8  2007 IBMJava2-ppc-142

またエラー。もう何回エラーを出したことか・・・。もう一度やり直し。windowsマシンから玄箱へftpでファイルを送っていたのだけれど、そのときのメッセージにアスキーモードで送られていたような気がしたので、バイナリモードで送ってみる。

C:>ftp 192.168.11.10
Connected to 192.168.11.10.
220 ProFTPD 1.3.0 Server (Debian) [192.168.11.10]
User (192.168.11.10:(none)): nakahira
331 Password required for nakahira.
Password:
230 User nakahira logged in.
ftp> bin
200 Type set to I
ftp> hash
Hash mark printing On  ftp: (2048 bytes/hash mark) .
ftp> put IBMJava2-SDK-1.4.2-9.0.ppc.tgz
#################################################################
#################################################################
(省略)
############################################################
226 Transfer complete.
ftp: 66479398 bytes sent in 1419.86Seconds 46.82Kbytes/sec.
ftp> bye
221 Goodbye.

送ったjava SDKの展開に再々挑戦。

KURO-BOX:/usr/local/src# tar xvfz IBMJava2-SDK-1.4.2-9.0.ppc.tgz
IBMJava2-ppc-142/
IBMJava2-ppc-142/bin/
IBMJava2-ppc-142/bin/jar
IBMJava2-ppc-142/bin/jdb
IBMJava2-ppc-142/bin/idlj
(省略)

エラーも無く成功。良し。javaSDKを解凍した場所にリンクを張る。

KURO-BOX:/# cd /usr/local
KURO-BOX:/usr/local# ln -s /usr/local/src/IBMJava2-ppc-142/ java

javaのホームの環境変数を設定する。以下のような内容となった。

KURO-BOX:/usr/local# vi /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"

if [ "$BASH" ]; then
  PS1='u@h:w$ '
else
  if [ "`id -u`" -eq 0 ]; then
    PS1='# '
  else
    PS1='$ '
  fi
fi

#iexport PATH PS1

JAVA_HOME="/usr/local/java"
export JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/lib

export PHTH PS1

umask 022

再起動して設定を反映する。

KURO-BOX:/usr/local# reboot

起動後、javaの動作を確認する。(バージョンをチェックする)

nakahira@KURO-BOX:~$ java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM build cxppc32142-20070708 (SR9) (JIT enabled: jitc))
nakahira@KURO-BOX:~$

Tomcatをインストール

公式サイトからソースファイルをダウンロード

KURO-BOX:/usr/local/src# wget http://www.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-5
/v5.5.26/bin/apache-tomcat-5.5.26-compat.tar.gz
--04:13:51--  http://www.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26-compat.tar.gz
           => `apache-tomcat-5.5.26-compat.tar.gz'
Resolving www.meisei-u.ac.jp... 202.232.192.34
Connecting to www.meisei-u.ac.jp|202.232.192.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,650,793 (1.6M) [application/x-gzip]

100%[==============================================>] 1,650,793    378.81K/s    ETA 00:00

04:13:56 (362.97 KB/s) - `apache-tomcat-5.5.26-compat.tar.gz' saved [1650793/1650793]
KURO-BOX:/usr/local/src# wget http://www.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.tar.gz
--04:15:25--  http://www.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.tar.gz
           => `apache-tomcat-5.5.26.tar.gz'
Resolving www.meisei-u.ac.jp... 202.232.192.34
Connecting to www.meisei-u.ac.jp|202.232.192.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6,372,195 (6.1M) [application/x-gzip]

100%[==============================================================================================>] 6,372,195    359.38K/s    ETA 00:00

04:15:42 (366.50 KB/s) - `apache-tomcat-5.5.26.tar.gz' saved [6372195/6372195]

ダウンロードしたファイルを展開

KURO-BOX:/usr/local/src# tar xvzf apache-tomcat-5.5.26.tar.gz
(省略)
KURO-BOX:/usr/local/src# tar xvzf apache-tomcat-5.5.26-compat.tar.gz
(省略)

startup.shの編集。下記のように編集をした。

#!/bin/sh
# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
#
# $Id: startup.sh 385888 2006-03-14 21:04:40Z keith $
# -----------------------------------------------------------------------------

export JAVA_HOME=/usr/local/java

# Better OS/400 detection: see Bugzilla 31132
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> (.*)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "This file is needed to run this program"
    exit 1
  fi
fi

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

shutdown.shの編集。下記のように編集をした。

#!/bin/sh
# -----------------------------------------------------------------------------
# Stop script for the CATALINA Server
#
# $Id: shutdown.sh 385888 2006-03-14 21:04:40Z keith $
# -----------------------------------------------------------------------------
# -----------------------------------------------
export JAVA_HOME=/usr/local/java
# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> (.*)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
  echo "Cannot find $PRGDIR/$EXECUTABLE"
  echo "This file is needed to run this program"
  exit 1
fi

exec "$PRGDIR"/"$EXECUTABLE" stop "$@"

Tomcatの起動

KURO-BOX:/usr/local/src/apache-tomcat-5.5.26/bin# ./startup.sh
Using CATALINA_BASE:   /usr/local/src/apache-tomcat-5.5.26
Using CATALINA_HOME:   /usr/local/src/apache-tomcat-5.5.26
Using CATALINA_TMPDIR: /usr/local/src/apache-tomcat-5.5.26/temp
Using JRE_HOME:       /usr/local/java

tomcat_preview.pngJSPの表示テスト。玄箱へブラウザでアクセスする。ポートは8080でアクセス。私の環境ではアドレスはhttp://192.168.11.10:8080となった。右の画像のようなものが表示されて動作テストは上手くいった模様。初回アクセスでこの画面を表示するのにえらい時間がかかったけれど、2回目以降はそれほど時間はかからなかった。私の玄箱は初代玄箱で、cpuのスペックはPowerPC 200MHZという非力なもの。この性能で動的ウェブページを動かすのはやはりちょっと無理があるかも・・・。

Tomcatの終了

KURO-BOX:/usr/local/src/apache-tomcat-5.5.26/bin# ./shutdown.sh
Using CATALINA_BASE:   /usr/local/src/apache-tomcat-5.5.26
Using CATALINA_HOME:   /usr/local/src/apache-tomcat-5.5.26
Using CATALINA_TMPDIR: /usr/local/src/apache-tomcat-5.5.26/temp
Using JRE_HOME:       /usr/local/java
Created MBeanServer with ID: c46d84a:11a6ecb0581:-8000:KURO-BOX:1
Jun 10, 2008 4:26:34 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:354)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:219)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:206)
        at java.net.Socket.connect(Socket.java:483)
        at java.net.Socket.connect(Socket.java:433)
        at java.net.Socket.<init>(Socket.java:340)
        at java.net.Socket.<init>(Socket.java:151)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:395)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
        at java.lang.reflect.Method.invoke(Method.java:391)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:344)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:435)

tomcatとapacheの連携

tomcatのページにアクセスするにはプロトコルを8080に指定してアクセスしないとページが表示できないので、それをapacheのポート80からアクセスできるように設定をする。apacheのバージョンは2.2でtomcatのバージョンは5.5の場合の設定。

まずモジュールproxy_ajpをapacheに読み込ませるようにする。apache2.2のモジュールの設定では、/etc/apache2/mods-enable/以下に読み込ませるモジュールのシンボリックリンクがなければならない。その設定を次のコマンドで行う。

KURO-BOX:/etc/apache2# a2enmod proxy_ajp
Enabling proxy as a dependency
Module proxy installed; run /etc/init.d/apache2 force-reload to enable.
Module proxy_ajp installed; run /etc/init.d/apache2 force-reload to enable.

これで、/etc/apache2/mods-enable/以下にproxy_ajpのシンボリックリンクが作成される。具体的にはproxy.confとproxy.loadとproxy_ajp.loadの三つのファイルへのシンボリックリンクが先の操作で作成されている。

KURO-BOX:/etc/apache2# ls -l mods-enabled/
total 0
(省略)
lrwxrwxrwx 1 root root 28 Jun 16 17:04 proxy.conf -> ../mods-available/proxy.conf
lrwxrwxrwx 1 root root 28 Jun 16 17:04 proxy.load -> ../mods-available/proxy.load
lrwxrwxrwx 1 root root 32 Jun 16 17:04 proxy_ajp.load -> ../mods-available/proxy_ajp.load
(省略)

次に、apache2.confファイルの修正を行う。viでapache2.confファイルを開いて、その最下部に下記のコードを追記する。意味は、http://ドメイン/cdn-01-partにアクセスしたら、tomcatのルートページを表示させる、というもの。proxy_ajpはデフォルトで8009番のポートを使うように設定がされている。

<Location /cdn-01-part>
ProxyPass ajp://localhost:8009/
Order allow,deny
allow from all
</Location>

以上の設定をしたあとでapacheを再起動してブラウザでhttp://ドメイン/cdn-01-partへアクセスするとtomcatのルートページが表示されるようになる。

投稿日:

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)