Centos 7.0 安裝VNC服務

Centos 7.0 安裝VNC 並開機啓動



零、 停止並禁用防火牆;

[root@7_test ~]# systemctl stop firewalld.service
[root@7_test ~]# systemctl disable firewalld.service


一、安裝圖形界面,已安裝的就跳過。

[root@7_test ~]# yum groupinstall "X Window System"
[root@7_test ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
[root@7_test ~]# unlink /etc/systemd/system/default.target
[root@7_test ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
[root@7_test ~]# reboot


二、yum 安裝vnc包

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

三、修改配置信息

[root@7_test ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
[root@7_test ~]# vim /etc/systemd/system/vncserver@:1.service

修改前配置:

ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid


修改後配置:

ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

四、重新加載systemd

[root@7_test ~]# systemctl daemon-reload

五、爲vnc設定密碼

    [root@7_test ~]# vncpasswd


六、設置開機自動和啓動服務

[root@7_test ~]# systemctl enable vncserver@:1.service  
Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver@:1.service to /etc/systemd/system/vncserver@:1.service.

啓動報錯:

[root@7_test ~]# systemctl start  vncserver@:1.service  
Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.

處理方法:1.

[root@7_test ~]# rm -rf /tmp/.X11-unix/*

處理方法:2.

    有人說把 vncserver@:1.service 中的 Type 參數必爲: simple (本人未驗證)

    [root@7_test ~]# systemctl enable vncserver@:1.service
    Failed to issue method call: File exists

A: 此錯誤一般發生在systemctl enable創建系統連接到/etc/systemd/system/的時候。一般是在切換顯示管理器(例如從 GDM 到 KDM)時出現,這時/etc/systemd/system/vncserver@:1.service 已經存在。 要解決此問題,使用 systemctl -f enable 覆蓋原有鏈接,或者刪除已經存在的鏈接:

[root@7_test ~]# rm -rf /etc/systemd/system/vncserver@:1.service.

    Systemd_FAQ (簡體中文)

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