CentOS 7 安装 VNC

然后把防火墙关闭SElinux
[[email protected] ~]# vim /etc/sysconfig/selinux
SElinux=enforcing 修改为 SElinux=disabled 保存退出!

安装vnc 远程桌面管理软件

首先试试服务器装了VNC没
[[email protected] ~]# rpm -q tigervnc tigervnc-server
没安装的话会直接出现

package tigervnc is not installed
package tigervnc-server is not installed
如果没有安装X-Windows 桌面的话要先安装Xwindows

[[email protected] ~]# yum check-update
[[email protected] ~]# yum groupinstall "X Window System"
[[email protected] ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
[[email protected] ~]# reboot
第一步,安装VNC packages:

[[email protected] ~]# yum install tigervnc-server -y

第二步,修改配置信息,在/etc/systemd/system/下建立文件夹[email protected]:1.service 把example config 文件从/lib/systemd/system/[email protected]复制到里面
[[email protected] ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

然后打开这个配置文件vim/etc/systemd/system/[email protected]:1.service替换掉默认用户名

改成root登入 必须改不然启动不了服务
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

[[email protected] ~]# systemctl daemon-reload 重新加载

第四步,为VNC设密码
[[email protected] ~]# 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 默认防火墙的可能需要
[[email protected] ~]# firewall-cmd --permanent --add-service vnc-server
[[email protected] ~]# systemctl restart firewalld.service

[[email protected] ~]# ps aux | grep vnc 查看服务启动没有
root 11609 0.0 0.0 112708 980 pts/0 S+ 14:57 0:00 grep --color=auto vnc 表示没有启动

[[email protected] ~]# vncserver 启动服务

[[email protected] ~]# ps aux | grep vnc 在查看服务
以下内容就是正常启动了!
root 20459 1.3 0.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 20466 0.0 0.0 113176 1196 pts/0 S 19:18 0:00 /bin/sh /root/.vnc/xstartup
root 20886 0.0 0.0 112712 980 pts/0 R+ 19:19 0:00 grep --color=auto vnc

第六步,设默认启动并开启VNC
[[email protected] ~]# systemctl enable [email protected]:1.service
[[email protected] ~]# systemctl start [email protected]:1.service
安装完成!
CentOS 7 安装 VNC

CentOS 7 安装 VNC

以下命令启动图形界面的 virtual Machine Manager 虚拟机
[[email protected] scsi_host]# virt-manager
CentOS 7 安装 VNC

转载于:https://blog.51cto.com/13938402/2342919