RHEL7.1配置VNC
來源:程序員人生 發布時間:2016-07-15 09:43:29 閱讀次數:2733次
1.安裝包
yum install vnc* -y
2.創建密碼
vncserver
3.創建參數文件
[root@single ~]# cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
4.修改參數文件
[root@single ~]# vi /lib/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i" --------修改處1:以root用戶為例,-l后修改成用戶名
PIDFile=/root/.vnc/%H%i.pid --------修改處2:.vnc前設置用戶的家目錄,root為/root
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
如果使用其他用戶登錄,需要
vncpasswd user_name
5.啟動
systemctl start vncserver@:1.service
6.如果想開機自啟動,那末
systemctl enable vncserver@:1.service
注:如果你是第1次接觸RHEL7,那末你此時肯定連接不上VNC,由于:
service iptables stop根本就關不掉防火墻!
需要:systemctl stop firewalld
制止防火墻開機自啟動:
[root@single ~]# systemctl disable firewalld
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'