阿娇开发978 发表于 2019-2-15 11:59:57

CentOS 7 安装 VNC

  然后把防火墙关闭SElinux
# vim /etc/sysconfig/selinux
SElinux=enforcing 修改为 SElinux=disabled 保存退出!
  安装vnc 远程桌面管理软件
  首先试试服务器装了VNC没
# rpm -q tigervnc tigervnc-server
没安装的话会直接出现
  package tigervnc is not installed
package tigervnc-server is not installed
如果没有安装X-Windows 桌面的话要先安装Xwindows
  # yum check-update
# yum groupinstall "X Window System"
# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
# reboot
第一步,安装VNC packages:
  # yum install tigervnc-server -y
  第二步,修改配置信息,在/etc/systemd/system/下建立文件夹vncserver@:1.service 把example config 文件从/lib/systemd/system/vncserver@.service复制到里面
# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  然后打开这个配置文件vim/etc/systemd/system/vncserver@:1.service替换掉默认用户名
  改成root登入 必须改不然启动不了服务
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
  # systemctl daemon-reload    重新加载
  第四步,为VNC设密码
# vncpasswd
  第五步,由于我这边的Centos 7 是用iptables防火墙的所以
vim /etc/sysconfig/iptables
创建iptables文件把以下内容添加进去
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT
  重启iptables
service iptables restart
  如果是用Centos 7 默认防火墙的可能需要
# firewall-cmd --permanent --add-service vnc-server
# systemctl restart firewalld.service
  # ps aux | grep vnc查看服务启动没有
root      116090.00.0 112708   980 pts/0    S+   14:57   0:00 grep --color=auto vnc表示没有启动
  # vncserver启动服务
  # ps aux | grep vnc 在查看服务
以下内容就是正常启动了!
root      204591.30.4 207660 38992 pts/0    Sl   19:18   0:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop localhost.localdomain:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000
root      204660.00.0 1131761196 pts/0    S    19:18   0:00 /bin/sh /root/.vnc/xstartup
root      208860.00.0 112712   980 pts/0    R+   19:19   0:00 grep --color=auto vnc
  第六步,设默认启动并开启VNC
# systemctl enable vncserver@:1.service
# systemctl start vncserver@:1.service
安装完成!
https://s1.运维网.com/images/blog/201901/15/85aba7ea7359308cae9c50fa65143eb5.png
https://s1.运维网.com/images/blog/201901/15/71fd013f594d8ca255d8bda8ef96e5c0.png
  以下命令启动图形界面的 virtual Machine Manager 虚拟机
# virt-manager
https://s1.运维网.com/images/blog/201901/17/f7be1412adf6e7a60eb1e742227ef56b.png



页: [1]
查看完整版本: CentOS 7 安装 VNC