安裝gnome圖形界面程序
第一步:在命令行下 輸入下面的命令來安裝Gnome包。
# yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
第二步:更新系統(tǒng)的運(yùn)行級(jí)別。
# ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
第三步:重啟機(jī)器。啟動(dòng)默認(rèn)進(jìn)入圖形界面。
# reboot
第一步,安裝VNC packages:
[root@wic ~]# yum install tigervnc-server -y
第二步,修改配置信息,在/etc/systemd/system/下建立文件夾vncserver@:1.service 把example config 文件從/lib/systemd/system/vncserver@.service復(fù)制到里面
[root@wic ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
然后打開這個(gè)配置文件/etc/systemd/system/vncserver@:1.service替換掉默認(rèn)用戶名
[root@wic ~]# vi /etc/systemd/system/vncserver@:1.service
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
找到上面兩行,這里我直接用root 用戶登錄,所以我替換成
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
第三步,重加載 systemd
[root@wic ~]# systemctl daemon-reload
第四步,為VNC設(shè)密碼
[root@wic ~]# vncpasswd
Password:
Verify:
第五步,由于我這邊的Centos 7 是用iptable防火墻的所以
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 默認(rèn)防火墻的可能需要
[root@wic ~]# firewall-cmd --permanent --add-service vnc-server
[root@wic ~]# systemctl restart firewalld.service
第六步,設(shè)默認(rèn)啟動(dòng)并開啟VNC
[root@wic ~]# systemctl enable vncserver@:1.service
[root@wic ~]# systemctl start vncserver@:1.service
vncserver
[root@wic ~]# vncserver
New 'iZuf6eggdv8svic125memxZ:1 (root)' desktop is iZuf6eggdv8svic125memxZ:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/iZuf6eggdv8svic125memxZ:1.log
[root@wic ~]# journalctl -xe
May 01 11:20:01 iZuf6eggdv8svic125memxZ systemd[1]: Started Session 94 of user root.
-- Subject: Unit session-94.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-94.scope has finished starting up.
--
-- The start-up result is done.
vncserver -kill :1
[root@wic ~]# vncserver -kill :1
Can't find file /root/.vnc/iZuf6eggdv8svic125memxZ:1.pid
You'll have to kill the Xvnc process manually
[root@wic ~]# journalctl -xe
May 01 11:20:01 iZuf6eggdv8svic125memxZ CROND[25434]: (root) CMD (/usr/lib64/sa/sa1 1 1)
May 01 11:20:58 iZuf6eggdv8svic125memxZ polkitd[2552]: Registered Authentication Agent for unix-process:25539:4596881 (system bus name :1.331 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/fr
May 01 11:20:58 iZuf6eggdv8svic125memxZ polkitd[2552]: Unregistered Authentication Agent for unix-process:25539:4596881 (system bus name :1.331, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loc
使用 VNC-Viewer 進(jìn)行連接,發(fā)現(xiàn)說
QQ瀏覽器截圖20190501110530.png
不知道咋回事