1.安装Gnome桌面
这里是使用的脚本安装。代码如下: 加附件
#!/bin/sh
#This script is FREE and written by www.vpsyou.com
# install yum-fastestmirror
yum -y install yum-fastestmirror
# Create new soft download dir
mkdir -p /backup/www.vpsyou.com;
cd /backup/www.vpsyou.com;
# Install x window softwares
yum -y groupinstall "X Window System"
yum -y groupinstall "GNOME Desktop Environment"
yum -y install nc expect freenx
yum -y groupinstall chinese-support
#install firefox
yum -y install firefox
# Copy client.id_dsa.key to /backup/www.vpsyou.com/
# Please use FTP or winscp to download it
cp /etc/nxserver/client.id_dsa.key /backup/www.vpsyou.com/
chmod 755 /backup/www.vpsyou.com/client.id_dsa.key
# iptables
iptables -A INPUT -i lo -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p udp --sport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 5000 -j ACCEPT
iptables -A OUTPUT -p udp --sport 5000 -j ACCEPT
sed -i 's#SELINUX=enforcing#SELINUX=disabled'# /etc/selinux/config
echo "==========================="
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "======= Download FreeNX Windows software : ======= "
echo ""
echo "http://www.nomachine.com/download-client-windows.php"
echo ""
echo ""
echo "======= How to use FreeNX connect to your Linux X Window System: ======= "
echo "http://www.vpsyou.com/centos-install-desktop/"
echo ""
echo "Install X Window System Successful,Press any key to end..."
char=`get_char`
2.安装VNC
yum install vnc-server vnc* -y
3、配置和启动VNC
vi /etc/sysconfig/vncservers
4.为远程用户设置密码
vncserver:1
或者
vncpasswd 或者 vncpasswd root ##默认是root
5.修改远程桌面显示配置文件 目录在/root/.vnc
vi xstartup ##这个文件附件里面有
内容如下:
#!/bin/sh
# Add the following line to ensure you always have an xterm available.
# 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 &
6、开启VNC服务
/sbin/service vncserver start
/sbin/service vncserver stop
sbin/service vncserver restart
service vncserver restart
7.查看VNC监听的哪些端口
netstat -luntp | grep "vnc"
7.修改防火墙策略
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5801 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 6001 -j ACCEPT
8.重启防火墙
service iptables restart
9.开机启动VNC
vi /etc/rc.d/rc.local
/etc/init.d/vncserver start --新增一行
###########想杀掉已启动的VNC客户端如下:
vncserver -kill :1
vncserver -kill :2
10 Windows登录测试
VNC Viewer登录测试
也可以在网页登录测试 必须支持Java
http://ip:5801/