各種サーバ設定


NTP サーバ (xntpd) の設定

xntpd は標準で入っているので、/etc/rc.conf に xntpd を起動する設定を記述し、xntpd の動作設定ファイル /etc/ntp.conf を作成する。

/etc/rc.conf に追加する内容:

xntpd_enable="YES"
xntpd_flags=""

/etc/ntp.conf の内容:

server 133.31.180.6
driftfile /etc/ntp.drift

公開 NTP サーバは http://www.kt.rim.or.jp/~ksakai/ntp.html などを参照してネットワーク的に近いところを選択。
133.31.180.6 = sutntp.sut.ac.jp


Proxy サーバ (squid) のインストール


Web サーバ (apache) の設定

apache をインストールする。

# pkg_add apache-1.3.12.tgz

httpd.conf に設定する。

実行権限を仮想ユーザに設定する。
User net
Group www
サーバ管理者とサーバ名を設定する。
ServerAdmin net@uminari.yi.org
ServerName waffle.uminari.yi.org
たいしたアクセスないはずなのでコネクション数は減らしておく。
MinSpareServers 2
MaxSpareServers 4
StartServers 2
MaxClients 64
.shtml ファイルは SSI (Server Side Include) 処理とする。
AddType text/html .shtml
AddHandler server-parsed .shtml
.cgi ファイルは CGI (Common Gateway Interface) 処理とする。
AddHandler cgi-script .cgi

また、.bz2 や .rar などをバイナリデータ扱いするために、 mime.conf に設定する。

application/octet-stream        bin dms lha lzh exe class bz2 rar

http://uminari.yi.org/ の URL でアクセスした場合に返すデータを変えるために Name-based Virtual Host を設定する。Virtual Host 設定のためには IP アドレス情報が httpd.conf に必要であるので、上記まで設定した httpd.confhttpd.conf.base として、 /etc/dhclient-exit-hookshttpd.conf を生成するようにする。

#!/bin/sh

cd /usr/local/etc/apache
/bin/cp httpd.conf.base httpd.conf
if [ x$new_ip_address != x ]; then
    /bin/cat<<EOF>>httpd.conf

<Directory "/home/net/www">
    Options MultiViews Indexes FollowSymLinks Includes ExecCGI
    DirectoryIndex index.shtml index.html index.htm
    AllowOverride AuthConfig Limit
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost $new_ip_address

<VirtualHost $new_ip_address>
    DocumentRoot /usr/local/www/data
    ServerName $new_ip_address
</VirtualHost>

<VirtualHost $new_ip_address>
    DocumentRoot /home/net/www
    ServerName uminari.yi.org
    CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-uminari.log 604800" combined
</VirtualHost>

<VirtualHost 192.168.1.1>
    DocumentRoot /home/net/www
    ServerName uminari.yi.org
    CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-local.log 604800" combined
</VirtualHost>
EOF

    if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ] && \
       [ -f /var/run/httpd.pid ]; then
        /bin/kill -USR1 `cat /var/run/httpd.pid`
    fi
fi

SMTP サーバ (postfix) の設定

postfix をインストールする。

# pkg_add postfix-19991231.08.tgz

postfix では、仮想ユーザとして postfix、グループとして postfix と maildrop を必要とする。pkg_add からも作成できるが、ID を指定できないので、 pkg_add の前にあらかじめこれらのユーザとグループを作成しておいたほうがいい。

/usr/local/etc/postfix/main.cf を編集する。

queue_directory = /var/spool/postfix
command_directory = /usr/local/sbin
daemon_directory = /usr/local/libexec/postfix

mail_owner = postfix
default_privs = nobody

myhostname = waffle.uminari.yi.org
mydomain = uminari.yi.org
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, $mydomain

mail_spool_directory = /var/mail
mailbox_command = /usr/local/bin/procmail

mynetworks = 192.168.1.0/24, 127.0.0.0/8

local_destination_concurrency_limit = 2
default_destination_concurrency_limit = 10
debug_peer_level = 2
debugger_command =
    PATH=/usr/bin:/usr/X11R6/bin
    xxgdb $daemon_directory/$process_name $process_id & sleep 5

allow_mail_to_commands = alias,forward,include

relayhost = プロバイダのメールサーバ

設定のチェックを行い、問題がなければ、起動する。

# /usr/local/sbin/postfix check
# /usr/local/sbin/postfix start

自動起動用のスクリプト /usr/local/etc/rc.d/postfix.sh を作成する。

#!/bin/sh
if [ -x /usr/local/sbin/postfix -a -f /usr/local/etc/postfix/main.cf ]; then
    /usr/local/sbin/postfix start
    echo -n ' postfix'
fi

POP3 サーバ (popper) の設定

poppoer をインストールする。

# pkg_add qpopper-2.53.tgz

/etc/inetd.conf に設定する。

pop3    stream  tcp     nowait  root    /usr/local/libexec/popper       popper

Mailing List (fml) の設定

# make install
perl ./makefml install
---NOT USING configuration file (for the first time)

   THIS HOST (waffle.uminari.yi.org) IS [i386-unknown-freebsd3.5.1]

---Please Define Your Fml System Configurations

Personal Use or ML-Admin-Group-Shared or fmlserv you use?
Personal, Group, Fmlserv (personal/group/fmlserv) [personal]

DOMAIN NAME               [uminari.yi.org]
FQDN                      [waffle.uminari.yi.org]
EXEC FILES DIRECTORY      [/usr/local/fml]
TOP LEVEL ML DIRECTORY    [/var/spool/ml]

Language (Japanese or English) [English] Japanese

TimeZone (TZ: e.g. +0900, -0300) [+0900]

Samba の設定

Samba をインストールする。

# pkg_add ja-samba-2.0.5a.2.tgz

プライベートネットワークのホストに対してのみファイルアクセスを許可する。
その他のパラメータ、わりと嘘 (ぉ
いや、そのうち……

[global]
    server string = Gateway (samba %v)
    dead time = 36000
    hosts allow = localhost 192.168.1.
    workgroup = uec

    encrypt passwords = yes 
    security = user
    domain_master = yes
    preferred master = yes 
    local master = yes
    os level = 65
    wins support = yes

    client code page = 932
    coding system = euc
    socket options = IPTOS_LOWDELAY TCP_NODELAY
    getwd cache = yes
;    oplocks = false
;    fake oplocks = no

[homes]
    comment = Home Directories
    browseable = no
    read only = no
    create mode = 0644
# cd /usr/local/samba/
# mkdir private
# chmod 500 private
# cd /usr/src/samba-2.0.6/source/script/
# chmod 755 mksmbpasswd.sh
# cat /etc/passwd | ./mksmbpasswd.sh >/usr/local/samba/private/smbpasswd

[ Home LAN ]