VNC远程桌面阿里云Centos7

Zss 发表于:

一.如果是本地的centos一般都安装了图形界面,没有的话安装一个

阿里云默认是没安装的,将图形界面安装好,设置为图形界面启动,然后reboot

 

1.安装图形界面
yum groups install “MATE Desktop”

图形界面的卸载:

yum groupremove  ‘X Window System’

yum  groupremove ‘GNOME Desktop’

2.获取当前默认启动界面
systemctl get-default
3.设置为图形启动
systemctl set-default multi-user.target //设置成命令模式
systemctl set-default graphical.target //设置成图形模式

 

二.安装配置 tigervnc-server

1.安装vnc–servervnc

yum install tigervnc-server tigervnc

2.Centos7需要配置的文件/lib/systemd/system/vncserver@.service,复制一份文件,并改名为vncserver@:1.service

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

3.将/lib/systemd/system/vncserver@.service改为以下

——————————————————————————————

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

[Service]
Type=simple
User=root

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i”
PIDFile=/root/.vnc/%H%i.pid

[Install]
WantedBy=multi-user.target

——————————————————————————————

4.将 /etc/systemd/system/vncserver@:1.service 改为以下

——————————————————————————————

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

[Service]
Type=forking
User=root

# Clean any existing files in /tmp/.X11-unix environment
ExecStart=/usr/bin/vncserver :1 -geometry 1280×1024 -depth 16 -securitytypes=none -fp /usr/share/X11/fonts/misc
ExecStop=/usr/bin/vncserver -kill :1

[Install]
WantedBy=multi-user.target

——————————————————————————————

5.设置登陆密码:vncpasswd

6.更新systemctl

systemctl daemon-reload

7.开启vnc

systemctl start vncserver@:1.service   开启

systemctl status vncserver@:1.service   查看状态

8.查看端口状态:netstat -lnt | grep 590*

9.查看报错信息:grep vnc /var/log/messages

10.添加端口5901或者关闭防火墙,且在阿里云上也需要设置入规则

# service firewalld status; #查看防火墙状态

(disabled 表明 已经禁止开启启动 enable 表示开机自启,inactive 表示防火墙关闭状态 activated(running)表示为开启状态)

# service firewalld start;  或者 #systemctl start firewalld.service;#开启防火墙

# service firewalld stop;  或者 #systemctl stop firewalld.service;#关闭防火墙

# service firewalld restart;  或者 #systemctl restart firewalld.service;  #重启防火墙

# systemctl disable firewalld.service#禁止防火墙开启自启

# systemctl enable firewalld#设置防火墙开机启动

11.使用软件来连接  ip:5901 来连接       下载:VNC-Viewer-6.0.1-Windows-64bit