虚拟化容器,大数据,DBA,中间件,监控。

阿里云ECS Centos7.2/Centos7.4配置gnome图形界面并安装vnc服务

09 10月
作者:admin|分类:应用管理

Centos7.2/Centos7.4配置gnome图形界面并安装vnc服务

 

 

1,首先,需要更新系统。

#: yum update -y

#: rebbot

2,然后,安装gnome环境包。

 #: yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y

现在,我们要在服务器上安装 VNC 服务器了。

4. yum 安装vnc
 #:yum install -y tigervnc  tigervnc-server tigervnc-server-module  -y

5 配置vnc

编辑

# vim /lib/systemd/sytem/vncserver@.service

找到下面这几行,用自己的用户名替换掉 。我的用户名是 root 所以我用 root 来替换掉 :

ExecStart=/sbin/runuser -l -c "/usr/bin/vncserver %i"

PIDFile=/home//.vnc/%H%i.pid


替换为

ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1024x768 -depth 16"
PIDFile=/root/.vnc/%H%i.pid


 /lib/systemd/system/vncserver@.service 改为 /lib/systemd/system/vncserver@:1.service

#mv /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service


重启 systemd

#systemctl daemon-reload

6.最后还要设置一下用户的 VNC 密码。要设置某个用户的密码,必须要有能通过 sudo 切换到用户的权限,这里我用 root 的权限,执行“直接vncpasswd”就可以了。

执行#vncpasswd 

blob.png

7.开启服务

设置开机启动

#systemctl enable  vncserver@:1.service

启动服务

#systemctl start vncserver:1.serivce

如果执行systemctl start vncserver:1.serivce 出现下面错误,重启服务器即可

blob.png

 

重启后。即可使用vnc了。可以使用ps 命令看到服务已经启动

blob.png

现在我们已经在运行 CentOS 7 / RHEL 7 的服务器上安装配置好了 VNC 服务器,可以使用vnc客户端进行连接。

如果需要中文图形,可以使用使用以上命令后重启系统.


# localectl set-locale LANG=zh_CN.UTF-8


安装realvnc viewer 使用客户端连接

blob.png

出现下图。点击continue

blob.png

输入设置的vnc密码

blob.png

登陆成功!

blob.png

 

 

如果服务器开启了防火墙,则需要允许vnc通过防火墙

# firewall-cmd --permanent --add-service vnc-server

重启防火墙

# systemctl restart firewalld.service




以上是旧版VNC软件安装方法。现在VNC软件已经更新。

2,然后,安装gnome环境包。

 #: yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y

现在,我们要在服务器上安装 VNC 服务器了。

4. yum 安装vnc
 #:yum install -y tigervnc  tigervnc-server tigervnc-server-module  -y

5 配置vnc

/usr/lib/systemd/system/vncserver@.service 将此文件复制到/etc/systemd/system/vncserver@:1.service

将<user>内容替换成root 用户,我这里使用root账号。

最后添加服务,并打开防火墙。

[root@centos7 ~]# cat /usr/lib/systemd/system/vncserver@.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Replace <USER> with the actual user name and edit vncserver
#    parameters appropriately
#   ("User=<USER>" and "/home/<USER>/.vnc/%H%i.pid")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.


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

[Service]
Type=forking
User=<USER>

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

浏览2399 评论0
返回
目录
返回
首页
Linux系统配置Squid代理内网服务器上网功能 ORA-19527与ORA-00312和db_recovery_file_dest_size of 2048 MB is 0.00% used