转载 CentOS 7安装GNOME桌面 和 配置 VNC 服务器

CentOS 7安装GNOME桌面 和 配置 VNC 服务器
这是一个关于怎样在你的 CentOS 7 上安装GNOME桌面 和 配置 VNC 服务器的教程。当然这个教程也适合 RHEL 7 安装GNOME桌面 和 配置 VNC 服务器。

1、安装桌面
yum check-update
yum groupinstall "X Window System" "GNOME Desktop" -y

2、设置默认启动图形界面
unlink /etc/systemd/system/default.target
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

3、安装 VNC 服务器
yum install tigervnc-server -y

然后,我们需要在 /etc/systemd/system/ 目录里创建一个配置文件。我们可以将 /lib/systemd/sytem/[email protected] 拷贝一份配置文件范例过来。

cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

4、配置VNC服务器
vi /etc/systemd/system/vncserver@:1.service
然后打开这个配置文件/etc/systemd/system/vncserver@:1.service替换掉默认用户名
找到这一行
ExecStart=/sbin/runuser -l -c "/usr/bin/vncserver %i"
PIDFile=/home//.vnc/%H%i.pid
这里我直接用root 用户登录,所以我替换成
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

5、重加载 systemd
# systemctl daemon-reload

6、VNC设密码
# vncpasswd

7、配置防火墙iptables或者firewalld
vim /etc/sysconfig/iptables
在合适位置加上
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT
重启iptable
service iptables restart

如果是用Centos 7 默认防火墙的可能需要
# firewall-cmd --permanent --add-service vnc-server
# systemctl restart firewalld.service

扫描二维码关注公众号,回复: 3218183 查看本文章

8、设默认启动并开启VNC
# systemctl enable vncserver@:1.service
# systemctl start vncserver@:1.service

9、重新启动服务器
reboot

猜你喜欢

转载自www.cnblogs.com/SDYiHeng/p/9655708.html