linux环境

[root@server1 ~]# uname -a
Linux server1.52chenqi.cn 4.10.5-1.el6.elrepo.x86_64 #1 SMP Wed Mar 22 14:55:33 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@server1 ~]# cat /etc/issue
CentOS release 6.9 (Final)
Kernel \r on an \m

安装xfce

1.yum upgrade

[root@server1 ~]# yum upgrade
Loaded plugins: fastestmirror
Setting up Upgrade Process
Loading mirror speeds from cached hostfile
 * base: mirrors.syringanetworks.net
 * elrepo-kernel: repos.lax-noc.com
 * extras: mirror.hostduplex.com
 * updates: repos-lax.psychz.net

2.yum install -y wget

[root@server1 ~]# yum install -y wget
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.tocici.com
 * elrepo-kernel: repos.lax-noc.com
 * extras: mirror.hostduplex.com
 * updates: repos-lax.psychz.net
Package wget-1.12-10.el6.x86_64 already installed and latest version
Nothing to do

我已经装过了
3.wget http://www.rpmfind.net/linux/centos/6.9/extras/x86_64/Packages/epel-release-6-8.noarch.rpm

[root@server1 ~]# wget http://www.rpmfind.net/linux/centos/6.9/extras/x86_64/Packages/epel-release-6-8.noarch.rpm
--2018-05-31 09:40:29--  http://www.rpmfind.net/linux/centos/6.9/extras/x86_64/Packages/epel-release-6-8.noarch.rpm
Resolving www.rpmfind.net... 195.220.108.108
Connecting to www.rpmfind.net|195.220.108.108|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14540 (14K) [application/x-rpm]
Saving to: “epel-release-6-8.noarch.rpm”

100%[======================================>] 14,540      88.7K/s   in 0.2s

2018-05-31 09:40:30 (88.7 KB/s) - “epel-release-6-8.noarch.rpm” saved [14540/14540]

4.rpm -ivh epel-release-6-8.noarch.rpm

[root@server1 ~]# rpm -ivh epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
        package epel-release-6-8.noarch is already installed

5.如果已经安装了epel-release,请先卸载,再重新安装
# rpm -e epel-release
# rpm -ivh epel-release-6-8.noarch.rpm

[root@server1 ~]# rpm -e epel-release
warning: /etc/yum.repos.d/epel.repo saved as /etc/yum.repos.d/epel.repo.rpmsave
[root@server1 ~]# rpm -ivh epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

6.安装xfce yum groupinstall xfce

[root@server1 ~]# yum groupinstall xfce
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
 * base: repos.forethought.net
 * elrepo-kernel: repos.lax-noc.com
 * epel: mirrors.develooper.com
 * extras: mirror.hostduplex.com
 * updates: repos-lax.psychz.net
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> Running transaction check
---> Package NetworkManager-gnome.x86_64 1:0.8.1-113.el6 will be installed
--> Processing Dependency: NetworkManager-glib = 1:0.8.1-113.el6 for package: 1:NetworkManager-gnome-0.8.1-113.el6.x86_64
--> Processing Dependency: NetworkManager = 1:0.8.1-113.el6 for package: 1:NetworkManager-gnome-0.8.1-113.el6.x86_64
--> Processing Dependency: libnotify >= 0.4.3 for package: 1:NetworkManager-gnome-0.8.1-113.el6.x86_64
.......

7.安装vnc yum install vnc vnc-server

[root@server1 ~]# yum install tigervnc-server
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.syringanetworks.net
 * elrepo-kernel: repos.lax-noc.com
 * epel: mirrors.develooper.com
 * extras: mirror.hostduplex.com
.........

8.配置VNC系统及分辨率

vi /etc/sysconfig/vncservers

然后在内容中添加

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768"

上面的分辨率可以根据我们自己的需要修改,比如可以改成800x600等。
9.设置VNC密码 vncserver

[root@server1 ~]#  vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /root/.Xauthority does not exist

New 'server1.52chenqi.cn:1 (root)' desktop is server1.52chenqi.cn:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server1.52chenqi.cn:1.log

10.修改xstartup配置文件

vi /root/.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 &
startxfce4 &

11.设置权限以及重启VNC/设置开机启动

service vncserver restart
chkconfig vncserver on