Linux系统安装VNC

一、安装tigervnc-server VNC软件包

使用系统镜像文件iso,配置本地yum源来安装tigervnc,配置本地yum源方式参考:Linux本地yum源配置
配置后按照如下命令安装:

[root@localhost ~]# yum -y install tigervnc-server ###没有配置yum源可以使用 rpm -ivh安装

如果不方便配置本地yum源,可以根据系统版本下载对应的tigervnc相关的rpm包。
例如:

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

设置重启自动启动。

[root@localhost ~]# chkconfig --level 35 vncserver on
二、目的:以root用户启动
[root@localhost ~]# vim /etc/sysconfig/vncservers
VNCSERVERS="1:root"

以vnc使用用户登录系统,创建vnc密码,vncpasswd
[root@localhost ~]$ vncpasswd
Password: 输入密码
Password must be at least 6 characters - try again
Password: 再次输入密码
Verify:

启动服务一次,生成 /home/visitor/.vnc/xstartup

[root@localhost ~]$ vncserver

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

Starting applications specified in /home/visitor/.vnc/xstartup
Log file is /home/visitor/.vnc/localhost.localdomain:1.log
三,启动服务
[root@localhost ~]# /etc/init.d/vncserver start
正在启动 VNC 服务器:1:root
New 'localhost.localdomain:1 (visitor)' desktop is localhost.localdomain:1

Starting applications specified in /home/visitor/.vnc/xstartup

Log file is /home/student/.vnc/localhost.localdomain:2.log

[确定]
四.添加防火墙配置
[root@localhost ~]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT
[root@localhost ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]

PS: 有时因为网络安全要求,不能使用常用端口,需要更改vnc服务的默认端口,按照以下步骤即可: 1。修改vnc的默认端口
[root@localhost ~]# vim /usr/bin/vncserver
注释:修改如下两行中默认的端口5900为你想要修改的端口 118:$vncPort = 5900 + $displayNumber;
274: if (!bind(S, pack(‘S n x12’, $AF_INET, 5900 + $n))) {
2.重启vnc服务 [root@localhost ~]# /etc/init.d/vncserver restar
3.访问vnc时,比如使用VNC viewer访问,你访问的端口比如是:
192.168.2.11:9701 而你在/etc/sysconfig/vncserver中配置的桌面端口是 1:root 那么在第1步中配置文件中修改的端口号就应该是 9701-1=9700

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Major_ZYH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值