English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Centos7Centos6.xが大きく変わりました。
リモートデスクトップを一台のサーバーにインストールするために、多くの曲を通ってきました。このブログ記事を書くのは、純粋に記録のために、将来的に同じ問題に直面した場合に追跡できるようにすることです。
1あなたのシステムにvncのソフトウェアがインストールされていないと仮定して、まずvncをインストールします
yum -y install tigervnc-server tigervnc
2、Centos7以前のシステムでは、vncをインストールする場合、一般的に設定が必要です
[root@localhost ~]# cat /etc/sysconfig/vncservers # このファイルは以下に置き換えられました /lib/systemd/system/[email protected]
しかし、先ほど述べたように、Centos7設定が必要なファイルは
[root@localhost ~]# ll /lib/systemd/system/[email protected] -rw-r--r--. 1 ルート ルート 1744 6月 10 14Jun15 /lib/systemd/system/[email protected]
3:
、文件内有如下提示 # 1# Quick HowTo: /etc/systemd/system/. Copy this file to # 2vncserver@:<display>.service . Edit <USER> and vncserver parameters appropriately -# ("runuser -l <USER> /usr/bin/c -vncserver %i1 -vncserver %i2arg # 3`)-. Run `systemctl daemon # 4. Run `systemctl enable vncserver@:<display>.service
4、复制一份文件,并改名为vncserver@:1.service
[root@localhost ~]# cp /lib/systemd/system/[email protected]/lib/systemd/system/vncserver@:1.service
5、将文件中的<User>用你当前的用户替换,将%i替换为1
[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 :1 > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1280x720 -depth 24" PIDFile=/root/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
6、更新systemctl
systemctl daemon-reload
7、设置为自动启动
systemctl enable vncserver@:1.service
8、启动vnc服务
systemctl start vncserver@:1.service
9、在iptables中加入对应的端口5901(注意,如果有其他用户,那么也需要将端口加上。vnc的端口默认是5900 + n)
[root@localhost system]# cat /etc/sysconfig/iptables # iptablesサービスのためのサンプル設定 # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
注意:
1、ファイアウォールを設定または有効にしない場合、VNC Viewerを使用して接続すると、"connect:Connection timed out("が表示されます。10060)"エラー。"
2、この記事はrootユーザーを使用した例です。他のユーザーもログインする必要がある場合は、ファイルをこのようにコピーする必要があります。
cp /lib/systemd/system/[email protected]/lib/systemd/system/vncserver@:2.service
ファイル内の%iを2を使用して、vncpasswdに対応するユーザーの設定を行います。
3、UltraVNC、TigerVNC、またはRealVNC Viewerを使用してアクセスできます。私はwin7以下でこの3中のツールはすべて接続できます
ご読覧ありがとうございます。皆様のサポートに感謝します!