Solaris 11 で,gcc, binutils などをインストール
wget, make, m4, autoconf, automake, bison, binutils, gcc, emacs のインストール
- gcc, flex をパッケージでインストール
sudo pkg install gcc sudo pkg install flex
- Wget のインストール
cd /tmp wget http://ftp.jaist.ac.jp/pub/GNU/wget2-1.99.2.tar.gz gzip -d < wget2-1.99.2.tar.gz | tar -xvf - cd wget2-1.99.2 ./configure make sudo make install
- make, m4, autoconf, automake, bison, binutils, gcc, emacs のインストール
- 次のコマンドを実行して,スクリプトのダウンロードと実行を行っても良い
cd /tmp rm -f do-solaris-cc1.sh wget https://www.kkaneko.jp/tools/solaris/do-solaris-cc1.sh bash do-solaris-cc1.sh
- 次のスクリプトをコピー&ペーストして実行しても良い
【スクリプトの本体】
export PATH=/usr/bin:/usr/sbin:/sbin:/usr/local/bin export SRCURL=http://ftp.jaist.ac.jp/pub/GNU echo make-4.2.1 cd /tmp; if [ ! -f make-4.2.1.tar.gz ]; then wget ${SRCURL}/make/make-4.2.1.tar.gz fi cd /tmp; rm -rf make-4.2.1 cd /tmp; gzip -d < /tmp/make-4.2.1.tar.gz | tar -xvof - cd /tmp; cd make-4.2.1; ./configure --prefix=/usr/local cd /tmp; cd make-4.2.1; make clean cd /tmp; cd make-4.2.1; make cd /tmp; cd make-4.2.1; sudo make install sudo ln -s /usr/local/bin/make /usr/local/bin/gmake read -p 'Press Enter to Continue' Answer echo m4-1.4.18: cd /tmp; if [ ! -f m4-1.4.18.tar.gz ]; then wget ${SRCURL}/m4/m4-1.4.18.tar.gz fi cd /tmp; rm -rf m4-1.4.18 cd /tmp; gzip -d < /tmp/m4-1.4.18.tar.gz | tar -xvof - cd /tmp; cd m4-1.4.18; ./configure --prefix=/usr/local cd /tmp; cd m4-1.4.18; make clean cd /tmp; cd m4-1.4.18; make cd /tmp; cd m4-1.4.18; sudo make install read -p 'Press Enter to Continue' Answer echo autoconf-2.69: cd /tmp; if [ ! -f autoconf-2.69.tar.gz ]; then wget ${SRCURL}/autoconf/autoconf-2.69.tar.gz fi cd /tmp; rm -rf autoconf-2.69 cd /tmp; gzip -d < /tmp/autoconf-2.69.tar.gz | tar -xvof - cd /tmp; cd autoconf-2.69; ./configure cd /tmp; cd autoconf-2.69; make clean cd /tmp; cd autoconf-2.69; make cd /tmp; cd autoconf-2.69; sudo make install read -p 'Press Enter to Continue' Answer echo automake-1.16.1: cd /tmp; if [ ! -f automake-1.16.1.tar.gz ]; then wget ${SRCURL}/automake/automake-1.16.1.tar.gz fi cd /tmp; rm -rf automake-1.16.1 cd /tmp; gzip -d < /tmp/automake-1.16.1.tar.gz | tar -xvof - cd /tmp; cd automake-1.16.1; ./configure cd /tmp; cd automake-1.16.1; make clean cd /tmp; cd automake-1.16.1; make cd /tmp; cd automake-1.16.1; sudo make install read -p 'Press Enter to Continue' Answer echo bison-3.5 cd /tmp; if [ ! -f bison-3.5.tar.gz ]; then wget ${SRCURL}/bison/bison-3.5.tar.gz fi cd /tmp; rm -rf bison-1.875 cd /tmp; gzip -d < /tmp/bison-3.5.tar.gz | tar -xvof - cd /tmp; cd bison-3.5; ./configure --prefix=/usr/local cd /tmp; cd bison-3.5; make clean cd /tmp; cd bison-3.5; make cd /tmp; cd bison-3.5; sudo make install read -p 'Press Enter to Continue' Answer echo binutils-2.33.1: cd /tmp; if [ ! -f binutils-2.33.1.tar.gz ]; then wget ${SRCURL}/binutils/binutils-2.33.1.tar.gz fi cd /tmp; rm -rf binutils-2.33.1 cd /tmp; gzip -d < /tmp/binutils-2.33.1.tar.gz | tar -xvof - rm -f /usr/local/bin/ar /usr/local/bin/sparc*-sun-solaris*-ar rm -f /usr/local/bin/ranlib /usr/local/bin/sparc*-sun-solaris*-ranlib rm -f /usr/local/bin/nm /usr/local/bin/sparc*-sun-solaris*-nm rm -f /usr/local/bin/ar /usr/local/bin/i?86*-*-solaris*-ar rm -f /usr/local/bin/ranlib /usr/local/bin/i?86*-sun-solaris*-ranlib rm -f /usr/local/bin/nm /usr/local/bin/i?86*-*-solaris*-nm cd /tmp; cd binutils-2.33.1; ./configure --prefix=/usr/local --enable-shared # cd /tmp; cd binutils-2.33.1; ./configure --prefix=/usr/local --disable-shared --disable-nls cd /tmp; cd binutils-2.33.1; /usr/local/bin/make clean cd /tmp; cd binutils-2.33.1; /usr/local/bin/make cd /tmp; cd binutils-2.33.1; sudo /usr/local/bin/make install cd /tmp; rm -rf binutils-2.33.1 read -p 'Press Enter to Continue' Answer echo gcc-9.2.0 cd /tmp if [ ! -f gcc-9.2.0.tar.gz ]; then wget ${SRCURL}/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz fi # extract source file cd /tmp rm -rf gcc-9.2.0 gzip -d < gcc-9.2.0.tar.gz | /usr/bin/tar -xvof - # configure, make, and install mkdir /tmp/gcc-9.2.0/build cd /tmp/gcc-9.2.0/build ../configure --with-gnu-as --enable-shared /usr/local/bin/make bootstrap /usr/local/bin/make sudo /usr/local/bin/make install read -p 'Press Enter to Continue' Answer cd /tmp if [ ! -f emacs-26.3.tar.gz ]; then wget ${SRCURL}/emacs/emacs-26.3.tar.gz fi rm -rf /tmp/emacs-26.3 cd /tmp /usr/bin/gzip -d < /tmp/emacs-26.3.tar.gz | tar -xvof - cd /tmp/emacs-26.3 ./configure --prefix=/usr/local \ -with-gcc \ --with-site-lisp make sudo make install
- 次のコマンドを実行して,スクリプトのダウンロードと実行を行っても良い
gcc のテスト実行
cd /tmp/
rm -f /tmp/a.c
echo '#include<stdio.h>' > /tmp/a.c
echo 'int main() {' >> /tmp/a.c
echo 'printf( "sizeof(int) = %d\n", sizeof(int) );' >> /tmp/a.c
echo 'printf( "sizeof(long int) = %d\n", sizeof(long int) );' >> /tmp/a.c
echo 'printf( "sizeof(long long int) = %d\n", sizeof(long long int) );' >> /tmp/a.c
echo '} ' >> /tmp/a.c
# コンパイル
# int: 4バイト, long int: 4バイト, long long int: 8バイト
gcc -o a.out a.c
./a.out
OpenSSL, bind, zlib, tcp_wrappers を自前でインストール
以下の手順で、 OpenSSL, bind, zlib, tcp_wrappers は、最新のソースプログラムを使ってインストールしなおすことができる。
- vipw(sshd:x:22:22:::の追加)
- /etc/rc2.d/S86sshd の作成
- OpenSSL, bind, zlib, tcp_wrappers の順にインストール
OpenSSL, bind, zlib, tcp_wrappers, OpenSSH を一括してインストールするための SPARC/cc 用インストールスクリプトを作っています。
- 参考: SPARC/cc 用インストールスクリプト: do-solaris-cc2.sh
OpenSSL のインストール
下では、openssl-0.9.8g のように書いているが、必ず最新の OpenSSL と OpenSSH をインストールしてください(セキュリティ上の理由).
参考 Webページ:
- OpenSSL のページ: http://www.openssl.org
- ring サーバのページ: : http://www.ring.gr.jp
手順:
# openssl-0.9.8g.tar.gz を持ってくる
cd /tmp
gzip -d < openssl-0.9.8g.tar.gz | tar -xvof -
setenv CC gcc
# cc を持っているときは setenv CC cc
cd openssl-0.9.8g
./Configure solaris-x86-gcc
# SPARC マシンでは、次のように: ./Configure solaris-sparcv9-cc か ./Configure solaris-sparcv9-gcc
make clean
make
make test
rm -f /usr/local/ssl/lib/lib*
rm -f /usr/local/lib/libcrypto*
rm -f /usr/local/lib/libssl*
make install
bind のインストール
下では、bind-9.3.2-P2 と書いているが、必ず最新の bind をインストールしましょう(セキュリティ上の理由).
Solaris には、すでに bind が付属していますが(参照: man named)、 最新版の bind をインストールします。
参考 Webページ:
- BIND9: https://www.isc.org/bind/
- ring サーバのページ: : http://www.ring.gr.jp
setenv CC gcc
# cc を持っているときは setenv CC cc
rm -rf /tmp/bind
mkdir /tmp/bind
cd /tmp
# bind-9.3.2-P2.tar.gz を持ってくる
cd /tmp/bind
gzip -d < ../bind-9.3.2-P2.tar.gz | tar -xvf -
cd bind-9.3.2-P2
./configure --with-openssl --disable-ipv6
# IPv6 でつながっている場合は --enable-ipv6
make clean
make depend
make
make tests
pkill named
make -k install
zlib のインストール
参考 Webページ:
Solaris には、すでに zlib が付属しているみたいなのですが(参照: man libz)、zlib の最新版をインストールします。
- zlib のページ: : https://www.gzip.org/
手順:
# zlib-1.2.3.tar.gz をもってくる
cd /tmp
gzip -d < zlib-1.2.3.tar.gz | tar -xvof -
cd zlib-1.2.3
unsetenv CC
./configure --shared
make clean
make
make install
tcp_wrapper のインストール
Solaris には、 すでに、TCP Wrapper が付属しているのですが、 libwrap.a が欲しいので、tcp_wrapper をインストールすることにしています。 下では、tcp_wrappers_7.6と書いているが、最新版をインストールしましょ う(セキュリティ上の理由)。
# tcp_wrappers_7.6.tar.gz を持ってくる
cd /tmp
gzip -d < tcp_wrappers_7.6.tar.gz | tar -xvof -
setenv CC gcc
# cc を持っているときは setenv CC cc
cd tcp_wrappers_7.6
# OSの種類によってオプションが変わるためインストールするマシンの OSにあわせてMakefileを書き換える
# Solaris では、
# Makefile の REAL_DAEMON_DIR は /usr/local/sbin のように設定。
# Makefile の LIBS は Solaris 用のものを使う
make CC=gcc sunos5
# 手動でインストールするが、tcpd tcpdchk tcpdmatch try-from
# safe_finger のコピー先は、REAL_DAEMON_DIR で設定したディレク
# トリであること
mkdir /usr/local/sbin
mkdir /usr/local/man/man3
mkdir /usr/local/man/man5
mkdir /usr/local/man/man8
cp tcpd tcpdchk tcpdmatch try-from safe_finger /usr/local/sbin
cp tcpd.8 tcpdchk.8 tcpdmatch.8 /usr/local/man/man8
cp hosts_access.5 hosts_options.5 /usr/local/man/man5
cp hosts_access.3 /usr/local/man/man3
cp tcpd.h /usr/local/include
cp libwrap.a /usr/local/lib
OpenSSH を自前でインストール
Solaris 10 では
Solaris 10 の現在のバージョンでは、openssh を無理に入れ直さなくても良いかな、 と思っています。sshd_config, ssh_config ファイルを適切に書き換えて使う。
以下に書いているのは、Solaris 9 及び それ以前の Solaris での手順である。 Solaris 10 では、/etc/rc 関係の改良があり、下記の手順ではそのままでは 動かない(参考にはなるかも知れません)。
OpenSSH のインストール (Solaris 9 及び以前用)
今インストールされている OpenSSH のバージョンは「ssh -version」あるいは「ssh -V」を実行 するなどで、すぐ分かります。
Solaris には SUN の ssh が付属しているのですが、SUN の sshd は 止めて、OpenSSH の sshd を使うようにします。
下では openssh-4.3p2 と書いているが、最新版をインストールしましょう。
参考 Webページ:
- OpenSSH のページ: https://www.openssh.com/
- ポータブル版 OpenSSH のダウンロード: https://www.openssh.com/portable.html
手順:
makeを行う前に/etc/passwdファイルの最後の行に以下の1行を追加する
sshd:x:22:22:::
次の手順でインストールする。 注) Solaris 10 ではこのままでは動かない
# openssh-4.3p2.tar.gz を持ってくる
cd /tmp
gzip -d < openssh-4.3p2.tar.gz | tar -xvof -
setenv CC gcc
setenv CFLAGS "-I/usr/local/ssl/include"
setenv LDFLAGS "-L/usr/local/ssl/lib -L/usr/local/lib"
setenv LIBS -ldl
cd openssh-4.3p2
./configure --prefix=/usr/local --with-tcp-wrappers=/usr/local/lib --sysconfdir=/etc/openssh --localstatedir=/etc/openssh --x-includes=/usr/openwin/include --x-libraries=/usr/openwin/lib --with-ssl-dir=/usr/local/ssl --without-pam --with-ipv4-default
make clean
make
echo stop ssh daemon
sh /etc/rc2.d/S86sshd stop
/usr/bin/pkill -x -u 0 sshd
/usr/bin/pkill -x -u 0 sshd2
echo remove old configuration files
rm -rf /etc/openssh
mkdir /etc/openssh
rm -f /etc/ssh*
rm -rf /etc/ssh
rm -rf /etc/ssh2
rm -f /etc/rc2.d/S96sshd*
rm -f /etc/init.d/ssh
rm -f /etc/rc2.d/S80ssh
rm -f /etc/rc0.d/k40ssh
cd /usr/local/etc
# /usr/local/etc が存在するときに限り、次を実行
rm -f /usr/local/etc/ssh_config
rm -f /usr/local/etc/ssh_host_dsa_key
rm -f /usr/local/etc/ssh_host_dsa_key.pub
rm -f /usr/local/etc/ssh_host_key
rm -f /usr/local/etc/ssh_host_key.pub
rm -f /usr/local/etc/ssh_prng_cmds
rm -f /usr/local/etc/sshd_config
echo remove old binaries
rm -f /usr/local/bin/ssh*
rm -f /usr/local/sbin/ssh*
echo stop Solaris SUN ssh
mv /etc/rc2.d/K03sshd a_K03sshd
mv /etc/init.d/sshd /var/tmp
echo install
rm -rf /etc/ssh
ln -s /etc/openssh /etc/ssh
cd /tmp/openssh-4.3p2
cp /tmp/openssh-4.3p2/ssh_prng_cmds /etc/openssh/ssh_prng_cmds
cp /tmp/openssh-4.3p2/ssh_config /etc/openssh/ssh_config
cp /tmp/openssh-4.3p2/sshd_config /etc/openssh/sshd_config
make -k install
# エラーメッセージがでていないか、確認する
echo edit sshd_config automatically
cp /etc/openssh/sshd_config /tmp
cat /tmp/sshd_config | sed 's/\/etc\/ssh/\/etc\/openssh/g' | sed 's/\/usr\/libexec/\/usr\/local\/libexec/g' > /etc/openssh/sshd_config
# ここで、/etc/openssh/sshd_config を確認。好みで、sftp サーバ設定: sshd_configファイルを書き換え.Subsystem sftp /usr/local/libexec/sftp-server
# ここで、下の手順を見て /etc/rc2.d/S86sshd を作成してください
chmod 744 /etc/rc2.d/S86sshd
chgrp sys /etc/rc2.d/S86sshd
/etc/rc2.d/S86sshd start
/etc/rc2.d/S86sshd の作成
/etc/rc3.d/S89sshd が存在するときは、mv /etc/rc3.d/S89sshd /etc/rc3.d/a_S89sshd を実行すること。 /etc/init.d/sshd が存在するときは、mv /etc/init.d/sshd /etc/init.d/a_sshd を実行すること。
#!/sbin/sh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
# ident "@(#)sshd 1.1 01/09/19 SMI"
#
# If sshd is configured (/etc/ssh/sshd_config exists and is readable),
# the start it up.
# Checks to see if RSA, and DSA host keys are available
# if any of these keys are not present, the respective keys are created.
# this script is for openssh. this script is originally from Solaris 9.
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
# KEYDIR=/etc/ssh
KEYDIR=/etc/openssh
# KEYGEN="/usr/bin/ssh-keygen -q"
KEYGEN="/usr/local/bin/ssh-keygen -q"
PIDFILE=/var/run/sshd.pid
case $1 in
'start')
if [ -x /usr/local/bin/ssh-keygen ]; then
if [ ! -f "$KEYDIR/ssh_host_rsa_key" ]; then
echo "Creating new RSA public/private host key pair"
$KEYGEN -f $KEYDIR/ssh_host_rsa_key -t rsa -N ''
fi
if [ ! -f "$KEYDIR/ssh_host_dsa_key" ]; then
echo "Creating new DSA public/private host key pair"
$KEYGEN -f $KEYDIR/ssh_host_dsa_key -t dsa -N ''
fi
fi
[ -x /usr/local/sbin/sshd ] && /usr/local/sbin/sshd -f /etc/openssh/sshd_config &
;;
'stop')
#
# If we are switching Run level downwards then we disconnect
# all connections.
#
# Otherwise we just kill the master daemon that is listening
# and leave the connections active
if [ -z "$_INIT_RUN_LEVEL" ]; then
set -- `/usr/bin/who -r`
_INIT_RUN_LEVEL="$7"
_INIT_PREV_LEVEL="$9"
fi
if [ $_INIT_RUN_LEVEL -lt $_INIT_PREV_LEVEL ]; then
/usr/bin/pkill -u 0 -x sshd
fi
if [ -f "$PIDFILE" ]; then
/usr/bin/kill -TERM `/usr/bin/cat $PIDFILE`
fi
;;
'restart')
if [ -f "$PIDFILE" ]; then
/usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
fi
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac