running vncserver on centos7

install

yum install tigervnc-server xorg-x11-fonts-Type1

init

使vncserver运行在5905端口.
/etc/systemd/system/vncserver@:5.service

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking

#相应用户user的uid.
XDG_RUNTIME_DIR="/run/user/1002"
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l <user> -c "/usr/bin/vncserver %i"
PIDFile=/home/<user>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

sudo systemctl enable vncserver@:5.service
sudo systemctl start vncserver@:5.service

配置vncserver

#vim .vnc/config

# securitytypes=vncauth,tlsvnc
# desktop=sandbox
# geometry=2000x1200
# localhost
# alwaysshared
#
geometry=1920x1080

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.