美文网首页
怎样在 阿里云主机(CentOS 7.x) 上安装和配置 VNC

怎样在 阿里云主机(CentOS 7.x) 上安装和配置 VNC

作者: 凤非飞 | 来源:发表于2019-05-01 11:26 被阅读0次

安装gnome图形界面程序

第一步:在命令行下 输入下面的命令来安装Gnome包。

   # yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
第二步:更新系统的运行级别。

   # ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

第三步:重启机器。启动默认进入图形界面。
   # reboot


第一步,安装VNC packages:

[root@wic ~]# yum install tigervnc-server -y

第二步,修改配置信息,在/etc/systemd/system/下建立文件夹vncserver@:1.service 把example config 文件从/lib/systemd/system/vncserver@.service复制到里面

[root@wic ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

然后打开这个配置文件/etc/systemd/system/vncserver@:1.service替换掉默认用户名

[root@wic ~]# vi /etc/systemd/system/vncserver@:1.service
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid

找到上面两行,这里我直接用root 用户登录,所以我替换成

ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

第三步,重加载 systemd

[root@wic ~]# systemctl daemon-reload

第四步,为VNC设密码

[root@wic ~]# vncpasswd
Password:
Verify:

第五步,由于我这边的Centos 7 是用iptable防火墙的所以

vim /etc/sysconfig/iptables

在合适位置加上

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT

重启iptable

service iptables restart

如果是用Centos 7 默认防火墙的可能需要

[root@wic ~]# firewall-cmd --permanent --add-service vnc-server
[root@wic ~]# systemctl restart firewalld.service

第六步,设默认启动并开启VNC

[root@wic ~]# systemctl enable vncserver@:1.service
[root@wic ~]# systemctl start vncserver@:1.service

vncserver

[root@wic ~]# vncserver
New 'iZuf6eggdv8svic125memxZ:1 (root)' desktop is iZuf6eggdv8svic125memxZ:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/iZuf6eggdv8svic125memxZ:1.log

[root@wic ~]# journalctl -xe
May 01 11:20:01 iZuf6eggdv8svic125memxZ systemd[1]: Started Session 94 of user root.
-- Subject: Unit session-94.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-94.scope has finished starting up.
-- 
-- The start-up result is done.

vncserver -kill :1

[root@wic ~]#  vncserver -kill :1
Can't find file /root/.vnc/iZuf6eggdv8svic125memxZ:1.pid
You'll have to kill the Xvnc process manually

[root@wic ~]#  journalctl -xe
May 01 11:20:01 iZuf6eggdv8svic125memxZ CROND[25434]: (root) CMD (/usr/lib64/sa/sa1 1 1)
May 01 11:20:58 iZuf6eggdv8svic125memxZ polkitd[2552]: Registered Authentication Agent for unix-process:25539:4596881 (system bus name :1.331 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/fr
May 01 11:20:58 iZuf6eggdv8svic125memxZ polkitd[2552]: Unregistered Authentication Agent for unix-process:25539:4596881 (system bus name :1.331, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loc

使用 VNC-Viewer 进行连接,发现说


QQ浏览器截图20190501110530.png

不知道咋回事

相关文章

网友评论

      本文标题:怎样在 阿里云主机(CentOS 7.x) 上安装和配置 VNC

      本文链接:https://www.haomeiwen.com/subject/dfvinqtx.html