一、安裝圖形界面
1、安裝X-Window圖形界面
shell> yum -y groupinstall "X Window System" shell> yum -y install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts # 由於yum源部分軟件包的更新,採用原來的方式安裝會因缺少軟件包,而使Xvnc服務不能正常啟動。 # 通過journalctl -xe查看日誌信息,如有以下報錯信息,是因為缺少庫文件導致。 # Dec 10 10:54:47 91donkey gnome-session: libGL error: unable to load driver: swrast_dri.so # Dec 10 10:54:47 91donkey gnome-session: libGL error: failed to load driver: swrast shell> yum -y install mesa-libGL-devel
2、設置默認啟動圖形界面
shell> unlink /etc/systemd/system/default.target shell> ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
3、安裝vnc server端
shell> yum -y install tigervnc-server
4、配置VNC
在 /etc/systemd/system/ 目錄裡創建一個配置文件。我們可以將 /lib/systemd/sytem/[email protected] 拷貝一份配置文件範例過來。
shell> cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
打開vncserver@:1.service,找到下面這幾行,替換掉部分 。
shell> vim /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 -geometry 1440x900 %i" PIDFile=/root/.vnc/%H%i.pid
注:修改分辨率在vncserver後添加參數-geometry 1440x900
5、重啟systemd
shell> systemctl daemon-reload
6、設置vnc密碼
shell> vncpasswd
7、設置開機啟動
- 關閉防火牆
shell> systemctl stop firewalld.service
- 永久開機啟動服務
shell> systemctl enable vncserver@:1.service
- 啟動VNC服務
shell> systemctl start vncserver@:1.service
二、關閉桌面休眠
CentOS7圖形化關閉屏幕保護
注:可能會因為軟件包的升級,界面展現形式略有區別,僅供參考。
操作:Application—System Tools—Setting—Hardware—Power Saving—Blank screen—never
作者:龍龍小寶
原文:https://www.cnblogs.com/91donkey/p/11249668.html