欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vnc配置

程序员文章站 2022-07-12 23:51:39
...

Centos7之前的系统,如果安装vnc一般都需要配置

[[email protected] ~]# cat /etc/sysconfig/vncservers 
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/[email protected]

Centos7需要配置的文件在

[[email protected] ~]# ll /lib/systemd/system/[email protected]
-rw-r--r--. 1 root root 1744 Jun 10 14:15 /lib/systemd/system/[email protected]

具体操作

# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/[email protected]:<display>.service
# 2. Edit <USER> and vncserver parameters appropriately
#  ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable [email protected]:<display>.service

复制一份文件,并改名为[email protected]:1.service

[[email protected] ~]# cp /lib/systemd/system/[email protected]/lib/systemd/system/[email protected]:1.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=/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1280x720 -depth 24"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
#重启
systemctl daemon-reload
systemctl enable [email protected]:1.service
systemctl start [email protected]:1.service

非root用户登陆黑屏问题

vncserver :4 -geometry 1280x800
# 其他参数
vncserver :4 -depth 24 -geometry 1920x1080 -nolisten tcp -localhost

 

上一篇: 数组常用的api

下一篇: