Wednesday, November 24, 2010

ติดตั้ง VNC remote desktop ใน centos 5 vps

ในที่นี้ผมจะกล่าวถึงการติดตั้ง VNC remote desktop + gnome ใน VPS ที่มีระบบเป็น Centos 5 นะครับ เนื่องจากถ้าใครใช้ VPS ก็ได้มาแต่ ssh ใช้งานผ่าน comamnd line ในการ config ค่าต่างๆ แต่ถ้าเราอยากได้แบบ desktop บางละจะทำไงมีวิธีมาบอกครับ หลังจากลองผิดถูกมาหลายครั้ง -_-

วิธีติดตั้ง desktop ให้กับ VPS centos 5 มีดังนี้

1. ให้เราติดตั้ง VNC , gnome desktop , xterm กันก่อน
yum groupinstall "GNOME Desktop Environment"
yum install vnc-server xterm
2. สร้าง user เพื่อใช้งาน
useradd kop
และกำหนดรหัสผ่าน
passwd kop
3. เข้าไปยัง user ที่สร้างมาใหม่ของผมคือ kop
su kop cd ~
4. จากนั้นสร้างรหัสผ่านของ vncserver ด้วย
vncpasswd
ตอนนี้ใน /home/kop ของเราจะต้องมีไฟล์ passwd อยู่ในโฟลเดอร์ .vnc
]$ pwd /home/kop
$ ls .vnc/ passwd
5. สั่งให้เริ่มทำการ vncserver
vncserver :1
// อธิบาย vncserver :1 << ใช้งาน display 1
6. ให้ทำการแก้ไขไฟล์ xstartup
$ pwd /home/kop/.vnc
$ vi 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 &
ให้เปลี่ยนเป็น
#!/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" &
gnome-session &
6. สังเกตุตอนนี้เราจะมีไฟล์ดังนี้
]$ pwd /home/kop/.vnc
$ ls linux-champ:1.log  linux-champ:1.pid  passwd  xstartup
7. ทำการปิดและเปิด vncserver ใหม่อีกรอบ
$ vncserver -kill :1
Killing Xvnc process ID 32506
$ vncserver :1
New 'linux-champ:1 (kop)' desktop is linux-champ:1  Starting applications specified in /home/kop/.vnc/xstartup Log file is /home/kop/.vnc/linux-champ:1.log

// อธิบาย vncserver -kill :1 << ปิด display 1 ทิ้ง
// แล้วก็ค่อยเปิดใหม่ vncserver :1 8. ให้ทำการโหลด http://www.tightvnc.com/download.html มาใช้งานส่วนบน ubuntu ก็ใช้ Remote Desktop Viewer ได้เลยมาอยู่แล้ว โดยใส่ค่าดังนี้
remote desktop viewer
จากนั้นใส่รหัสผ่านของข้อ 4 ลงไป เราก็จะได้หน้าตา GUI มาใช้งานละครับ
หมายเหตุ : ถ้าไม่ได้สามารถทำการเคลียร์ค่าของ vncserver ได้ดังนี้
rm -rf /tmp/.X1* rm ~/.vnc/*log
ที่มา : http://www.talk.web.id/2009/08/installing-vnc-remote-desktop-on-centos-vps/

0 comments:

Post a Comment

 
Design by GURU