-----------------------
RED HAT Linux 9
-----------------------
■VSFTPD
・VSFTPD 起動設定
chkconfig --level 2345 vsftpd on
・VSFTPD 起動
/etc/init.d/vsftpd start
※VSFTPDは、xinet.dにはない。
スタンドアロン起動になっている。
-----------------------
OPEN SSL
-----------------------
■ダウンロードURL
http://www.openssl.org/
■インストール
tar zxvf openssl-0.9.7c.tar.gz
cd openssl-0.9.7c
./config
make
su
make test
make install
-----------------------
Apache
-----------------------
■ダウンロードURL
http://www.apache.org/dist/httpd/
■インストール
tar zxvf httpd-2.0.48.tar.gz
cd httpd-2.0.48/
vi config.layout
<Layout Apache>
- prefix:/usr/local/apache2
+ prefix:/usr/local/apache
gcc がないので、gccを導入。
./configure --enable-so \
--enable-ssl \
--with-ssl=/usr/local/ssl
make
su
make install
/usr/local/apache/bin/httpd -l
でモジュール一覧を表示させられます.
mod_ssl.cとあったら成功です.
<サーバ証明書関連の準備>
まずは秘密鍵の生成です。
-randの後に乱数を指定します。
自分でファイルを用意してもいいですし、適当なファイルを指定してもいいです。
messagesにしたのはログファイルなので常に書き変わっているというところにあります。
出力ファイル名は特にドメイン名とかにする必要はありません。
# openssl genrsa -des3 -rand /var/log/messages -out honyarara.jp.pem 1024
パスフレーズなしでApacheを起動させるための鍵を生成します。
# openssl rsa -in honyarara.jp.pem -out nopass_honyarara.jp.pem
続いて認証局に送るCSRを作成します。
CSRは証明書を認証してもらうための情報です。
特に何も入力しなくても問題ないみたいですが。
# openssl req -new -key honyarara.jp.pem -out honyarara.jp.csr
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
Using configuration from /etc/ssl/openssl.cnf
Enter PEM pass phrase:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Tokyo
Locality Name (eg, city) []:Chiyoda-ku
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Example Corp.
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:hoge
Email Address []:hogehoge@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
続いて証明書を入手します。
VeriSignなどの外部機関に署名してもらうのがベターなのですが、お金がかかります。
お金が無いので自分で署名して証明書を発行してしまいましょう。
また、検証目的やイントラネットでの利用する場合でも使えると思います。
(-daysオプションで証明書の有効期限を設定できます)
# openssl x509 -days 9999 -req -in honyarara.jp.csr -signkey honyarara.jp.pem -out honyarara.jp.crt
以上で鍵は全部できました。確認すると。
honyarara.jp.pem =>秘密鍵
honyarara.jp.crt =>公開鍵
ということになります。
・Apacheのssl.confを編集して、公開鍵、秘密鍵の位置を設定しておきます。
SSLCertificateFile /usr/local/ssl/honyarara.jp.crt
SSLCertificateKeyFile /usr/local/ssl/nopass_honyarara.jp.pem
SSLを利用する場合は start ではなく startssl として Apache を起動します。
$ /usr/local/apache/bin/apachectl startssl
・確認作業
”https://サイト名”でアクセス。
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
●Config関連
・httpd.confの設定
vi /usr/local/apache/conf/httpd.conf
1)標準的な設定
#ServerName new.host.name:80
ServerName honyarara.jp:80
2)文字化け対策
#AddDefaultCharset ISO-8859-1
AddDefaultCharset none
LanguagePriority ja en da nl et fr de el it ko no pl pt pt-br ltz ca es sv tw
-----------------------
OpenSSH
-----------------------
■ダウンロードURL
ftp://ftp.jp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
■インストール
cd openssh-3.7.1p2
./configure --prefix=/usr/local --sysconfdir=/etc/ssh
make
su
/etc/rc.d/init.d/sshd stop
make install
/etc/rc.d/init.d/sshd start
●鍵生成
su somesuer
cd
#ssh-keygen -t rsa1
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
Generating public/private rsa1 key pair.
Enter file in which to save the key (/root/.ssh/identity):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/identity.
Your public key has been saved in /root/.ssh/identity.pub.
The key fingerprint is:
??:??:??:??:??:??:??:??:??:??:??:??:??:??:??:?? root@honyarara
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
cd ~/.ssh
cat identity.pub >> authorized_keys
chmod 600 authorized_keys
ls -la
su
vi /etc/ssh/sshd_config
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
・接続するクライアントの公開鍵の導入
cat ssh_host_key.pub >> authorized_keys
cat scpidenify_pub >> authorized_keys
cat somesuer_pubkey.pub >> authorized_keys
---------------------------------------------------
Java Install
---------------------------------------------------
■ダウンロードURL
http://java.sun.com/j2se/1.4.2/download.html
■インストール
chmod 755 j2sdk-1_4_2_02-linux-i586.bin
./j2sdk-1_4_2_02-linux-i586.bin
mv j2sdk1.4.2_02 /usr/local/
ln -s /usr/local/j2sdk1.4.2_02 /usr/local/java
---------------------------------------------------
tomcat-4.1.24
---------------------------------------------------
■ダウンロードURL
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/bin/
■インストール
tar zxf jakarta-tomcat-4.1.29.tar.gz
su
mv jakarta-tomcat-4.1.29 /usr/local/tomcat
export JAVA_HOME=/usr/local/Java
export ANT_HOME=/usr/local/ant
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin
export TOMCAT_HOME=/usr/local/tomcat
---------------------------------------------------
jakarta-tomcat-connectors jk2/release/v2.0.2
---------------------------------------------------
■ダウンロードURL
http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/release/v2.0.2/src/
■インストール
tar zxf jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-tomcat41=/usr/local/tomcat
cd server/apache2
vi Makefile
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
#EXTRA_CFLAGS= -g -02 -pthread
EXTRA_CFLAGS= -02 -pthread
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
make
cd jk/build/jk2/apache2
su
cp ./mod_jk2.so /usr/local/apache/modules/
---------------------------------------------------
設定
---------------------------------------------------
mkdir /home/hogewebapp
mkdir /home/hogewebapp/WEB-INF
mkdir /home/hogewebapp/WEB-INF/classes
vi /usr/local/apache/conf/httpd.conf
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
#● ADD
LoadModule jk2_module /usr/local/apache/modules/mod_jk2.so
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
vi /usr/local/apache/conf/workers2.properties
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
# Define the communication channel
[status:]
[uri:/jkstatus/*]
group=status:
[shm:]
disabled=1
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
tomcatId=localhost:8009
[uri:/examples/*]
info=Map the whole webapp
#解説:上記の例の場合、"http://www.xxxx.co.jp/examples/"以下のアクセスは
# Tomcatにより処理されます。
#● ADD
[uri:/hogewebapp/*]
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
vi /usr/local/tomcat/conf/server.xml
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
1) ADD
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
---↓↓↓↓↓---ここから---↓↓↓↓↓---
<!-- hogewebapp Append Start -->
<!-- Tomcat image Context -->
<Context path="/hogewebapp" docBase="/home/hogewebapp"
debug="0" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_hogewebapp_log." suffix=".txt"
timestamp="true"/>
</Context>
<!-- somesuer Append End -->
---↑↑↑↑↑---ここまで---↑↑↑↑↑---
2) 有効確認Coyote/JK2 AJP 1.3 Connector
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
3) 無効確認Ajp13Connector
<!--
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
-->
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
vi /home/hogewebapp/WEB-INF/web.xml
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
</web-app>
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
■Tomcat停止、再起動
/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh
■Apache停止、再起動
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl sslstart
---------------------------------------------------
PostgreSQLセットアップ
---------------------------------------------------
■ダウンロードURL
ftp://ftp.sra.co.jp/pub/cmd/postgres/7.3.5/
■本体のインストール
tar zxf postgresql-7.3.4.tar.gz
cd postgresql-7.3.4
./configure
make
make check
su
make install
■DB操作用のユーザの作成
su
vi /etc/bashrc
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
#------------------------------
# by honyarara.jp
#------------------------------
export JAVA_HOME=/usr/local/Java
export ANT_HOME=/usr/local/ant
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin
export TOMCAT_HOME=/usr/local/tomcat
export PATH=/usr/local/pgsql/bin:$PATH
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
adduser honyadbadminin
passwd ????????
■DBの初期化と自動起動の設定
su honyadbadminin
cd
mkdir PostgreSQL_LOG
# -E EUC_JP でデフォルトの符号化方式をEUC_JPとするDBとなる。
initdb -E EUC_JP -D /home/honyadbadminin/PostgreSQL_DATA
■tcp/ip socket通信をサポートして立ち上がるように設定
vi /home/honyadbadminin/PostgreSQL_DATA/postgresql.conf
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
tcpip_socket = true
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
■PostgreSQL起動
pg_ctl start -D /home/honyadbadminin/PostgreSQL_DATA -l /home/honyadbadminin/PostgreSQL_LOG/postgrelog
postmaster -D /home/honyadbadminin/PostgreSQL_DATA -i >/home/honyadbadminin/PostgreSQL_LOG/postgrelog
vi /etc/rc.local
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
#--------------------------------------------
# for PostgreSQL Server START
#--------------------------------------------
#su -c '/usr/local/pgsql/bin/pg_ctl start -D /home/honyadbadminin/PostgreSQL_DATA -l /home/honyadbadminin/PostgreSQL_LOG/postgrelog' honyadbadminin
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
■データベースのインスタンス作成
createdb HONYARARADB
psql -l
■データベース接続用のユーザをPostgreSQL内に作成。
psql HONYARARADB
CREATE USER honyauser WITH PASSWORD '???????';
7.2から新しいユーザ認証の方法として"md5"が追加されています.md5は cryptと似ていますが,pg_shadowに格納されるパスワードが暗号化(実際に はmd5 hash)されている点が異なります.通信経路のみならず,データベー ス中のパスワードも暗号化されるため,7.2ではmd5の利用が推奨されていま す.ただし,md5は7.2よりも前のバージョンのフロントエンドではサポート されていないため,7.2よりも前のバージョンのフロントエンドをサポート する必要がある場合には使用できません.
md5認証で使用できる暗号化されたパスワードを設定するためには,7.2で追 加された新しいキーワード"ENCRYPTED"を追加してALTER USER文を使用しま す.使用例:
ALTER USER ishii WITH ENCRYPTED PASSWORD 'whatever';
#CREATE USER honyauser PASSWORD '???????';
※間違えたときは次のコマンドでUSERをDropする。
##DROP USER honyauser;
■データベーステーブルの作成
psql HONYARARADB
CREATE TABLE honyatest (
code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
title VARCHAR(40),
date_prod DATE,
kind VARCHAR(10)
);
■データベーステーブルへのアクセス権限の設定
GRANT UPDATE ON testusertest TO honyauser;
GRANT SELECT ON testusertest TO honyauser;
GRANT INSERT ON testusertest TO honyauser;
GRANT DELETE ON testusertest TO honyauser;
pg_ctl stop -D /home/honyadbadminin/PostgreSQL_DATA -m immediate
pg_ctl start -D /home/honyadbadminin/PostgreSQL_DATA -l /home/honyadbadminin/PostgreSQL_LOG/postgrelog
■JDBCドライバの設定
http://jdbc.postgresql.org/download.html
・Tomcatの起動時読み込みLibに追加しておく。(ln -s の方が良いかもしれない。)
#cp pg73jdbc3.jar /usr/local/tomcat/shared/lib/pg73jdbc3.jar
ln -s /usr/local/lib/JDBC/pg73jdbc3.jar /usr/local/tomcat/shared/lib/pg73jdbc3.jar
■pg_hba.conf ファイルによるクライアント認証の設定
vi /home/honyadbadmin/PostgreSQL_DATA/pg_hba.conf
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host all all 192.168.???.??? 255.255.255.255 trust
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
■自動起動設定
vi /etc/rc.d/init.d/postgresql
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
#!/bin/bash
# RedHat Stuff
#
# chkconfig: 345 85 15
# description: Starts and stops the PostgreSQL backend daemon\
# that handles all database requests.
# processname: postmaster
#
# Config Variables
#
PGCTL=/usr/local/pgsql/bin/pg_ctl
DBDIR=/home/honyadbadmin/PostgreSQL_DATA
LOGDIR=/home/honyadbadmin/PostgreSQL_LOG/postgrelog
case "$1" in
start)
if [ -f $PGCTL ]; then
su honyadbadmin -c "$PGCTL -D $DBDIR -l $LOGDIR start"
echo -n ' PostgreSQL'
fi
;;
stop)
su honyadbadmin -c "$PGCTL -D $DBDIR -l $LOGDIR stop"
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exit 0
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
chmod 755 /etc/rc.d/init.d/postgresql
・自動起動のchkconfigを設定
chkconfig --level 345 postgresql on
chkconfig --list postgresql
---------------------------------------------------
RealServerセットアップ
---------------------------------------------------
■ダウンロードURL
http://www.realnetworks.com/products/media_delivery.html
■本体のインストール
chmod 755 rs902-linux-22libc6-ia32.bin
unzip RNKey-Helix_Server-90-43179121887171656.zip
#(memoする) /home/somesuer/archive_new/RealServer/RNKey-Helix_Server-90-43179121887171656.lic
su
./rs902-linux-22libc6-ia32.bin
★1★
Enter the complete path to the directory where you want
Helix Server to be installed. You must specify the full
pathname of the directory and have write privileges to
the chosen directory.
Directory: [/home/somesuer/archive_new/RealServer]: /usr/local/real
★2★
Please enter a username and password that you will use
to access the web-based Helix Server Administrator, monitors,
and live encoders:
Username []: testuser
★3★
Please enter a port on which Helix Server will listen for
PNA connections. These connections have URLs that begin
with "pnm://"
Port [7070]:
★4★
Please enter a port on which Helix Server will listen for
RTSP connections. These connections have URLs that begin
with "rtsp://"
Port [554]:
★5★
Please enter a port on which Helix Server will listen for
HTTP connections. These connections have URLs that begin
with "http://"
Port [80]: 8080
★6★
Please enter a port on which Helix Server will listen for
MMS connections. These connections have URLs that begin
with "mms://"
Port [????]:
★7★
Helix Server will listen for Administrator requests on the
port shown. This port has been initialized to a random value
for security. Please verify now that this pre-assigned port
will not interfere with ports already in use on your system;
you can change it if necessary.
Port [???????]:
★8★
You have selected the following Helix Server configuration:
Admin User/Password: testuser/****
Encoder User/Password: testuser/****
Monitor Password: ****
RTSP Port: 554
HTTP Port: 8080
PNA Port: 7070
MMS Port: ????
Admin Port: ??????
Destination: /usr/local/real
Enter [F]inish to begin copying files, or [P]revious to go
back to the previous prompts: [F]:
---------------------------------------------------
NTP セットアップ
---------------------------------------------------
■NTPのConfigファイル設定
vi /etc/ntp.conf
-----------------------------------------------------------------------
# -- CLIENT NETWORK -------
# Permit systems on this network to synchronize with this
# time service. Do not permit those systems to modify the
# configuration of this service. Also, do not use those
# systems as peers for synchronization.
# restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap
# 自サイトのクライアントの時間取得を許可する。
restrict 192.168.???.??? mask 255.255.255.0 notrust nomodify notrap
# --- OUR TIMESERVERS -----
# or remove the default restrict line
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
# restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery
# server mytrustedtimeserverip
# 時刻同期させてもらうサーバーを指定する。
# clock.tl.fukuoka-u.ac.jp
restrict 133.100.11.8 mask 255.255.255.255 nomodify notrap noquery
server 133.100.11.8
# clock.nc.fukuoka-u.ac.jp
restrict 133.100.9.2 mask 255.255.255.255 nomodify notrap noquery
server 133.100.9.2
# ntp1.jst.mfeed.ad.jp
restrict 210.173.160.27 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.27
# ntp2.jst.mfeed.ad.jp
restrict 210.173.160.57 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.57
# ntp3.jst.mfeed.ad.jp
restrict 210.173.160.87 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.87
# timekeeper.isi.edu
restrict 128.9.176.30 mask 255.255.255.255 nomodify notrap noquery
server 128.9.176.30
-----------------------------------------------------------------------
■NTPの起動
/etc/init.d/ntpd start
■自動起動の設定
/sbin/chkconfig ntpd on
■自動起動の確認
/sbin/chkconfig --list ntpd
■時刻同期の確認
/usr/sbin/ntpq -p