CentOS 7 安裝 VNC

然後把防火牆關閉SElinux
[root@localhost ~]# vim /etc/sysconfig/selinux
SElinux=enforcing 修改爲 SElinux=disabled 保存退出!

安裝vnc 遠程桌面管理軟件

首先試試服務器裝了VNC沒
[root@linuxidc ~]# rpm -q tigervnc tigervnc-server
沒安裝的話會直接出現

package tigervnc is not installed
package tigervnc-server is not installed
如果沒有安裝X-Windows 桌面的話要先安裝Xwindows

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

[root@linuxidc ~]# yum install tigervnc-server -y

第二步,修改配置信息,在/etc/systemd/system/下建立文件夾vncserver@:1.service 把example config 文件從/lib/systemd/system/[email protected]複製到裏面
[root@linuxidc ~]# cp /lib/systemd/system/[email protected] /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

[root@linuxidc ~]# systemctl daemon-reload 重新加載

第四步,爲VNC設密碼
[root@linuxidc ~]# 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 默認防火牆的可能需要
[root@linuxidc ~]# firewall-cmd --permanent --add-service vnc-server
[root@linuxidc ~]# systemctl restart firewalld.service

[root@localhost ~]# ps aux | grep vnc 查看服務啓動沒有
root 11609 0.0 0.0 112708 980 pts/0 S+ 14:57 0:00 grep --color=auto vnc 表示沒有啓動

[root@localhost ~]# vncserver 啓動服務

[root@localhost ~]# 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
[root@linuxidc ~]# systemctl enable vncserver@:1.service
[root@linuxidc ~]# systemctl start vncserver@:1.service
安裝完成!
CentOS 7 安裝 VNC

CentOS 7 安裝 VNC

以下命令啓動圖形界面的 virtual Machine Manager 虛擬機
[root@localhost scsi_host]# virt-manager
CentOS 7 安裝 VNC

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章