Centos及Redhat环境配置VNC远程图形化

Centos7、Redhat7

#安装tigervnc-server软件包

[root@localhost ~]# mount /dev/cdrom /mnt

mount: /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# cd /mnt

[root@localhost mnt]# cd Packages/

[root@localhost Packages]# rpm -ivh tigervnc-server-1.3.1-9.el7.x86_64.rpm

[root@localhost Packages]# cd /lib/systemd/system

[root@localhost system]# cp vncserver@.service vncserver@:2.service

[root@localhost system]# vim vncserver@:2.service

将文件中的<User>用你当前的用户替换,将%i替换为:1

[Unit]

Description=Remote desktop service (VNC)

After=syslog.target network.target

 

[Service]

Type=forking

# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'

ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver :1"

PIDFile=/root/.vnc/%H%1.pid

ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'

 

[Install]

WantedBy=multi-user.target

 

[root@localhost system]# systemctl start vncserver@:2.service

[root@localhost system]# systemctl enable vncserver@:2.service

 

使用vncview 输入192.168.52.79:2即可打开。

 

 

注意:非正常关机启动后,会报

PID 4286 read from file /root/.vnc/localhost.localdomain:1.pid does not exist or is a zombie

或者 PID file /root/.vnc/localhost.localdomain:2.pid not readable (yet?) after start.

解决方法:cd /tmp/.X11-unix

Rm -rf  *

 

Centos6,Redhat6

[root@localhost ~]# mount /dev/cdrom /mnt

mount: /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# cd /mnt

[root@localhost mnt]# cd Packages/

[root@localhost Packages]# rpm -ivh tigervnc-server-1.1.0-5.el6_4.1.x86_64.rpm

[root@localhost ~]# vncserver

 

You will require a password to access your desktops.

 

Password:overseas

Verify:overseas

xauth:  creating new authority file /root/.Xauthority

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

 

Creating default startup script /root/.vnc/xstartup

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/localhost.localdomain:1.log

[root@localhost ~]# cd /root/.vnc/

[root@localhost .vnc]# vim xstartup

注释:#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#twm &

添加:gnome-session &

[root@localhost .vnc]# vim /etc/sysconfig/vncservers

添加:

VNCSERVERS="2:root"

VNCSERVERARGS[2]= "-geometry 1024x768"

[root@localhost .vnc]# chmod 777 /root/.vnc/xstartup

[root@localhost .vnc]# service iptables stop 或者将5901,5902端口放行,以此类推

[root@localhost .vnc]# chkconfig vncserver on

[root@localhost .vnc]# /etc/init.d/vncserver start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值