CentOS作業 のバックアップ(No.7)

※※このサイトは2012年頃より更新を停止しています。※※

VPSサービスにて

2007年5月2日、とあるVPSレンタルサービスで仮想OSを借りた。
OSはCentOS4。環境構築作業をいつでも再現できるようにメモしておく。

参考:CentOSで自宅サーバー構築
参考:Linux/CentOSネットワーク実験室


環境

OS : CentOS 4.3(初期状態)
メモリ : 128MB
ディスク: 5GB

初期状態からすること

環境チェック

# cat /etc/redhat-release
# df
# mount
# env

rootの情報変更

# passwd root
# vi .bash_profile
HISTSIZE=50000
export HISTSIZE

yumでアップデート

# yum check-update
# yum update
# yum clean all

ユーザ追加

# adduser username
# passwd username
Changing password for user username.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

sshdのコンフィグ変更

# vi /etc/ssh/sshd_config
  #### 変更
  #Port 22
  Port 10022   # まぁつまりデフォルトとは別の任意の番号に変更するってこと
  #PermitRootLogin yes
  PermitRootLogin no
  #### 追加
  AllowUsers      username   # 特定のユーザだけSSHログインを許可する
# service sshd restart

/etc/hosts.allow や /etc/hosts.deny の編集

特定の端末からのみSSHを許可するようにしたい場合、手っ取り早く下記で指定する。

# vi /etc/hosts.deny
sshd: ALL
# vi /etc/hosts.allow
sshd: hostname.domainname

各種ユーティリティのインストール

# yum install nmap cpio diffutils file system-config-date

とりあえず。必要に応じて追加してきゃいいかな。

ホスト名とかを設定

# cp -a  /etc/hosts /etc/hosts.ORIGINAL
# cp -a /etc/sysconfig/network /etc/sysconfig/network.ORIGINAL
# vi /etc/sysconfig/network
NETWORKING="yes"
GATEWAY="123.123.123.1"
HOSTNAME="myhostname"
# vi /etc/hosts
127.0.0.1 myhostname localhost localhost.localdomain
123.123.123.50 myhostname.mydomain.net
# hostname myhostname
# shutdown -r now

続きは随時追記します。(2007-05-04 18:41)

サーバアプリ導入/設定

参考:Kazuの挑戦日記 - CentOS4.2でLAN内(社内)用サーバ構築の手順

DNS - bind9 の導入(2007-05-17)

自宅でやってみるDNSサーバ構築練習
DNS マスターサーバ
DNS セカンダリサーバ

  1. BIND9関連パッケージをインストール
    # yum install bind-libs bind-utils bind caching-nameserver
  2. /etc/named.conf の編集
    //
    // named.conf for Red Hat caching-nameserver
    //
    
    options {
            directory "/var/named";
            dump-file "/var/named/data/cache_dump.db";
            statistics-file "/var/named/data/named_stats.txt";
            /*
             * If there is a firewall between you and nameservers you want
             * to talk to, you might need to uncomment the query-source
             * directive below.  Previous versions of BIND always asked
             * questions using port 53, but BIND 8.1 uses an unprivileged
             * port by default.
             */
             // query-source address * port 53;
    };
    
    //
    // a caching only nameserver config
    //
    controls {
            inet 127.0.0.1 allow { localhost; } keys { rndckey; };
    };
    
    zone "." IN {
            type hint;
            file "named.ca";
    };
    
    zone "localdomain" IN {
            type master;
            file "localdomain.zone";
            allow-update { none; };
    };
    
    zone "localhost" IN {
            type master;
            file "localhost.zone";
            allow-update { none; };
    };
    
    zone "0.0.127.in-addr.arpa" IN {
            type master;
            file "named.local";
            allow-update { none; };
    };
    
    zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
            type master;
            file "named.ip6.local";
            allow-update { none; };
    };
    
    zone "255.in-addr.arpa" IN {
            type master;
            file "named.broadcast";
            allow-update { none; };
    };
    
    zone "0.in-addr.arpa" IN {
            type master;
            file "named.zero";
            allow-update { none; };
    };
    
    zone "mydomain.net" IN {
            type master;
            file "mydomain.net";
            allow-update { none; };
            allow-transfer { 123.123.123.30/32; };
    };
    
    include "/etc/rndc.key";
  3. /var/named/mydomain.net の編集
    $TTL    86400
    @               IN SOA  hostname.mydomain.net.       root (
                                  2007050200      ; serial
                                  3H              ; refresh
                                  15M             ; retry
                                  1W              ; expiry
                                  1D )            ; minimum
    
                    IN NS           hostname.mydomain.net.
                    IN NS           ns4.sphere.ad.jp.
                    IN MX 10        @
    
                    IN A            123.123.123.92
    hostname        IN A            123.123.123.92
    www             IN A            123.123.123.92
  4. /etc/rndc.conf の編集
    /* $Id: rndc.conf,v 1.7.2.1 2004/03/09 06:09:27 marka Exp $ */
    
    /*
     * Sample rndc configuration file.
     */
    
    options {
            default-server  123.123.123.92;
            default-key     "rndckey";
    };
    
    server localhost {
            key     "rndckey";
    };
    
    include "/etc/rndc.key";
    
    namedの起動
    # service named start
    # chkconfig --level 345 named on

メール - postfix の導入(2007-05-17)

  1. パッケージインストールとデフォMTAスイッチ
    # yum install postfix
    # system-switch-mail   (コマンドがなければ不要)
  2. /etc/postfix/main.cf の編集
    myhostname = mydomain.net
    
    mydomain = $myhostname
    
    myorigin = $myhostname
    
    inet_interfaces = all
    #inet_interfaces = localhost
    
    relay_domains = $mydestination
    
    smtpd_sasl_auth_enable = yes
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination
  3. Submission Portの設定
    # vi /etc/postfix/master.cf
    以下を加え(書き換え)る。
    submission   inet    n       -       n       -       -       smtpd
     -o smtpd_sasl_auth_enable=yes -o smtpd_etrn_restrictions=reject
  4. saslauthd を使えるように
    # saslpasswd2 -u mydomein.net mail_user
    Password:
    Again (for verification):
    # chown postfix /etc/sasldb2
  5. サービス自動起動
    # chkconfig --level 345 saslauthd on
    # service postfix start
    # service saslauthd start
  6. /etc/aliases をチェック
    UNIXユーザを作成した時に、/etc/aliases
    にそのユーザ名のエイリアス設定がされてないか、ちゃんと確認しておくこと。

dovecot の導入 (2007-05-17)

  1. パッケージインストール
    # yum install dovecot
    Dependencies Resolved
    
    =============================================================================
     Package                 Arch       Version          Repository        Size
    =============================================================================
    Installing:
     dovecot                 x86_64     0.99.11-4.EL4    base              676 k
    Installing for dependencies:
     mysql                   x86_64     4.1.20-2.RHEL4.1  update            2.9 M
     perl-DBI                x86_64     1.40-8           base              467 k
     postgresql-libs         x86_64     7.4.16-1.RHEL4.1  update            155 k
  2. /etc/dovecot.conf の編集
    なんかデフォルトではIMAPしかlistenしてなかった。
    ので、popのlistenを有効に。
    protocols = imap imaps pop3 pop3s
    
    imap_listen = *
    pop3_listen = *
    
    imaps_listen = *
    pop3s_listen = *
    
    ssl_disable = no
  3. サービス起動
    # chkconfig --level 345 dovecot on
    確認は下記のコマンドで。
    # netstat -an --tcp
トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS