Linux > SetupServerNote

サーバー構築作業メモ

クライアントからvncでアクセスする

まずは動かしてみる(最低限の設定)

  • クライアントからアクセスするユーザーでvncserverプロセスを起動させる。
  • 起動コマンドはいろいろあるらしいが、基本は以下のコマンドを使用するっぽい。
/etc/init.d/vncserver {start | stop | status}
  • ネットで載ってたやり方を何も考えず実施してみた。ただのvncserverコマンド。今のユーザーで始めてこのコマンドをたたくとパスワードを決めさせられる。
$ vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  creating new authority file /home/[ユーザー名]/.Xauthority

New 'localhost.localdomain:1 ([ユーザー名])' desktop is localhost.localdomain:1

Creating default startup script /home/[ユーザー名]/.vnc/xstartup
Starting applications specified in /home/[ユーザー名]/.vnc/xstartup
Log file is /home/[ユーザー名]/.vnc/localhost.localdomain:1.log
  • で、同時にvncserverが起動しちゃったっぽい。
$ /etc/init.d/vncserver status
Xvnc (pid 4636) を実行中...
  • とりあえずVNCViewerをインストしてクライアント(Windows7で動作保障されてないが…)から接続を試みた。ファイアウォールの設定が必要だが、あっけなく接続成功。

ウィンドウマネージャの変更

  • が、デフォルトではウィンドウマネージャ(?)がtwmというものが設定されていて、見た目がかなり寂しい。。xstartupファイルの最後の一行を「twm &」から「gnome-session &」に変更。
$ cat /home/[ユーザー名]/.vnc/xstartup
#!/bin/sh

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

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
  • 以下のようにディスプレイ番号を指定してvncserverを停止させた後、再度vncserverコマンドを実行すると、ディスプレイマネージャの変更が反映された。
$ vncserver -kill :1
Killing Xvnc process ID 5270
$ vncserver
・・・

起動設定

  • 起動スクリプト/etc/rc.d/init.d/vncserverが参照する/etc/sysconfig/vncserversに以下を追記しとく(rootユーザーでね)
VNCSERVERS="1:[ユーザー名]"
VNCSERVERARGS[1]="-geometry 1024x768"

よくわかんないこと

  • vncserverの起動方法(コマンド)がはっきりわかんない
  • ディスプレイ番号
    • vncserverで起動したときとかVNCViewerでアクセスするときの[ホスト名:1]みたいな「:1」の1はディスプレイ番号なるものらしい。詳細はよくわかんない!
  • VNCViewerからGUIでデスクトップ環境をさわれるんだけど、上部メニューの「システム」をさわろうとすると画面が止まっちゃって操作できなくなる。。

subversion + apache

手順

  1. apache を入れる
  2. mod_dav_svn を入れる
  3. subversion.conf を設定する

apache を入れる

  • が、CentOS5.5 にはapache は標準でインストールされている?
    • httpd = apache と考えてよいらしい。
# yum list installed | grep httpd
httpd.i386                            2.2.3-43.el5.centos              installed
httpd-manual.i386                     2.2.3-43.el5.centos              installed
system-config-httpd.noarch            5:1.3.3.3-1.el5                  installed

mod_dav_svn を入れる

  • subversion というパッケージもあるが、apache 連携する場合はこっちを入れておけば問題ないらしい。
    • subversion + apache との連携に必要な依存パッケージも入れてくれるみたい。
# yum install mod_dav_svn
Loaded plugins: fastestmirror
...
Installed:
  mod_dav_svn.i386 0:1.4.2-4.el5_3.1

Dependency Installed:
  subversion.i386 0:1.4.2-4.el5_3.1

Complete!

subversion.conf の設定

  • ここで最もはまった。設定するsubversion.conf は以下にある。
/etc/httpd/conf.d/subversion.conf
  • 中身はこんな感じ。
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be readable and writable by the 'apache' user.  Note that if
# SELinux is enabled, the repositories must be labelled with a context
# which httpd can write to; this will happen by default for
# directories created in /var/www.  Use "restorecon -R /var/www/svn"
# to label the repositories if upgrading from a previous release.
#

#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#

#<Location /repos>
#   DAV svn
#   SVNParentPath /var/www/svn
#
#   # Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
#      AuthType Basic
#      AuthName "Authorization Realm"
#      AuthUserFile /path/to/passwdfile
#      Require valid-user
#   </LimitExcept>
#</Location>
  • 最低限必要な修正は以下のとおり。
<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn
#
#   # Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
#      AuthType Basic
#      AuthName "Authorization Realm"
#      AuthUserFile /path/to/passwdfile
#      Require valid-user
#   </LimitExcept>
</Location>
  • なんとなく説明
    • SVNParentPath で指定している「/var/www/svn」直下にリポジトリを作成することになる。
    • <Location /repos> の部分で指定している/repos はブラウザからアクセスするとき、上記のSVNParentPathに対応する。
    • 要は、/var/www/svn 直下にsandbox というリポジトリを作成した場合、ブラウザからはhttp://hostname/repos/sandbox とアクセスすればOK!
  • はまったこと
    • 最初はSVNParentPath に自分の好きなディレクトリを指定してブラウザからアクセスしていたが、何度やっても表示されない。
    • ブラウザには500エラーが表示され、httpdのエラーログには「(20014)Internal error: Can't open file...」が出力されていた。
    • ケースによるみたいだけど、今回SVNParentPath は/var/www/svn としておく必要があるみたい。それでアクセスできました。
最終更新:2011年04月07日 23:03