「Linux」カテゴリーアーカイブ

VNCサーバのインストールと設定

インストール

# yum install vnc-server

サービスの自動起動設定

# chkconfig vncserver on

VNCサーバの設定
/etc/sysconfig/vncservers

VNCSERVERS="1:user1 2:user2"
VNCSERVERARGS[1]="-geometry 800x600 -depth 16"
VNCSERVERARGS[2]="-geometry 800x600 -depth 16"

VNCパスワードの設定
/etc/sysconfig/vncserversで設定したユーザでログインして、vncpasswdでパスワードを設定する。
各ユーザのホームディレクトリ下の.vnc/xsartupを編集
コメントを2か所外す。

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

ファイアウォールの設定
VNCプロトコルは、5900 + 「ディスプレイ番号」のポートを使用する。
例えば、ディスプレイ番号が1の場合は、5901:tcpを開いておく
VNCサーバを起動する
サービスで起動

# service vncserver start

vncserverコマンドで起動(:1はディスプレイ番号)

# vncserver :1

vncserverコマンドで停止

# vncserver -kill :1

suでスーパーユーザー(root)になれるユーザーを限定する

1. /etc/pam.d/suファイルを開き、6行目の先頭のコメントを示す#を外す。

#auth       required     /lib/security/$ISA/pam_wheel.so use_uid

auth       required     /lib/security/$ISA/pam_wheel.so use_uid

2. スーパーユーザーになることを許可したいユーザーをwheelグループに追加する。
vigrコマンドで/etc/groupを編集するとよい。(wheelで始まる行の最後にユーザー名をカンマ区切りで追加する。)

wheel:x:10:root,user1,user2

ホスト名の変更

ホスト名の確認

# hostname

ホスト名の設定

# hostname host.example.com

hostnameコマンドによるホスト名の変更はLinuxの再起動により初期化される。
システム起動時のホスト名を設定するには、
/etc/sysconfig/networkのHOSTNAME
を変更する。
あと、/etc/hostsも変更しておく。
/etc/sysconfig/networkの変更後は、ネットワークの再起動が必要。

# /etc/init.d/network restart

yumの自動更新cronを設定する

yum-updatesdがインストールされている場合は、停止して削除しておく。
CentOS5初期設定 - CentOSで自宅サーバー構築

# /etc/init.d/yum-updatesd stop
# yum -y remove yum-updatesd

yum-fastestmirrorのインストール

# yum install yum-fastestmirror

yum-cronのインストール

# yum install yum-cron

自動更新を起動

# /etc/init.d/yum-cron start

自動更新の自動起動を設定

# chkconfig yum-cron on

更新対象からはずすパッケージを指定する場合は、/etc/yum.conf のexcludeを設定する。
・ワイルドカード(*)を使用できる。
・複数指定する場合は、スペースで区切る。

exclude=kernel*

postfixのmain.cfの設定

main.cfに少なくとも以下の設定が必要。
以下の例では、メールサーバがmail.example.com、ドメインがexample.com。

myhostname = mail.example.com
mydomain = example.com
# mydestinationに$mydomainを含めない場合、
# user@example.com宛てのメールが受信できない
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
#	mail.$mydomain, www.$mydomain, ftp.$mydomain
inet_interfaces = $myhostname, localhost
#mynetworks_style = subnet
mynetworks_style = host
# aliasesファイルの設定とエリアスデータベースの作成は別途必要
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
# home_mailboxは、dovecotのmail_locationの設定と合わせる。(※1)
# IMAPを使用する場合はdovecotでMaildir形式を使用する必要があるため、
# ここでもMaildirを設定する。
home_mailbox = Maildir/

※1 postfix + dovecot

設定のチェックは

postfix check

postfix + dovecot

postfixの配信メールがdovecotで受信できない。
/etc/postfix/main.cfのhome_mailboxと、/etc/dovecot.confのmail_locationが同じ場所を指すように設定する必要がある。
/etc/postfix/main.cf

home_mailbox = Maildir/

/etc/dovecot.conf

mail_location = maildir:~/Maildir

iptablesでftpを通す

iptablesでftpを通すには、以下のように21番ポートをあけるだけでは、LISTコマンドが通らない。

# iptables -A INPUT -p tcp --dport 21 -j ACCEPT

ip_conntrack_ftpとip_nat_ftp二つのモージュールをロードする必要がある。
/etc/sysconfig/iptables-configに以下の記述をしておけば、自動的にロードされる。

IPTABLES_MODULES="ip_conntrack_ftp ip_nat_ftp"

iptables-configを変更したら、iptablesを再起動する。

# service iptables restart

モジュールがロードされていることを確認。

# lsmod
Module                  Size  Used by
nf_nat_ftp              7361  0 
nf_conntrack_ftp       13761  1 nf_nat_ftp
...以下略

iptablesでftpを通す