PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

centos7怎么开启vnc服务

藏色散人
藏色散人 转载
2021-04-12 16:34:21 6878浏览

下面由centos教程栏目给大家介绍centos 7开启vnc服务,希望对需要的朋友有所帮助!

centos7配置vnc

一.安装

以root用户运行以下命令来安装vncserver;

yum install tigervnc-server

同样运行以下命令来安装vncviewer;

yum install vnc

停止并禁用防火墙;

systemctl stop firewalld.service
systemctl disable firewalld.service

二.配置

vncviewer基本上不用配置;

vncserver的配置,创建一个新的配置文件,以开启1号窗口为例(也可以同时开启多个窗口,修改数字即可),方法如下:

cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service

或者再增加一个窗口:

cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:2.service

编辑/lib/systemd/system/vncserver@:1.service,设置用户root相关参数

[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 800x600"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

三.应用

更新systemctl以使其生效;

systemctl daemon-reload

设置vncserver的密码;

 vncpasswd root

按提示输入密码以及确认密码

启动该服务用来启用vnc的1号窗口;

systemctl start vncserver@:1.service  或者 vncserver :1

关闭1号窗口:

systemctl stop vncserver@:1.service   或者 vncserver -kill :1

设置为开机自动启动;

systemctl enable vncserver@:1.service

End.

声明:本文转载于:csdn,如有侵犯,请联系admin@php.cn删除