About VNC startup

Source: Internet
Author: User
At the same time, you need to install VNCserver (one Centos and one Asianux) on two linux servers, but you have encountered the same problem. when you start the VNC, you cannot start it yourself. you need to enter vncserver to connect to it, the following is the solution: 1. install and configure VNC. both of my machines have been installed by default...

At the same time, you need to install VNCserver (one Centos and one Asianux) on two linux servers, but you have encountered the same problem. when you start the VNC, you cannot start it yourself. you need to enter vncserver to connect to it, the following is the solution: 1. install and configure VNC. by default, VNC is installed on both of my machines, but google is not installed.
Vncserver
Passwd: # The first time you run vncserver, you must enter the connection password.
Verify:
New 'localhost: 1 (root) 'desktop is localhost: 1
Starting applications specified in/root/. vnc/xstartup
Log file is/root/. vnc/localhost: 1.log
Join the service and enable it to start
# Chkconfig vncserver on
# Chkconfig -- list vncserver
Vncserver 0: off 1: off 2: on 3: on 4: on 5: on 6: off # check whether it is successful. 2-5 is on.
Configure the remote desktop environment
# Vi. vnc/xstartup
Unset SESSION_MANAGER # Remove the first two sentences #
Exec/etc/X11/xinit/xinitrc
Gnome-session & # This is what Centos uses
Startkde
Twm & ## SSH-like interface
Create a firewall policy:
# Iptables-a input-p tcp -- dport 5901-j ACCEPT # default VNC port 5901
# Iptables-L
Chain INPUT (policy ACCEPT)
Target prot opt source destination
ACCEPT tcp -- anywhere tcp dpt: 5901
Chain FORWARD (policy ACCEPT)
Target prot opt source destination
Chain OUTPUT (policy ACCEPT)
Target prot opt source destination
Save the firewall policy: many people forget this step. as a result, the connection fails after a restart.
# Iptables-save>/etc/sysconfig/iptables # generate a file to save the rules. I also use the service iptables save command to generate a rule file, but it cannot be loaded at startup.
The following scene shows a lot of detours: red is the incorrect process. please copy it by mistake. I started it with the vncserver command. both machines successfully saw the desktop, I was very excited. as a result, I couldn't connect after a restart. I had to enter the vncserver to connect. When I first found information on the Internet and said that VNC is user-level, I thought it would enable it to automatically execute the vncserver command at startup:
# Vi/etc/rc. d/rc. local
/Usr/bin/vncserver # if Centos is used, all the console will be started and stuck in the location where the user is about to be lost.
# Redflag can be started but cannot be connected
# Chkconfig vncserver off # I have tried to cancel the service, but I still cannot. The result is as follows:
Remove this sentence. after testing, we only need to modify the/etc/sysconfig/vncserver file:
# Vi/etc/sysconfig/vncserver
VNCSERVERS = "2: root" # Be sure to change it to 2 or 3. Otherwise, the connection will fail.
VNCSERVERARGS [2] = "-geometry 800*600" # How did TNND input the cross?
OK! Restart and verify. PS:/etc/rc. d/init. d/vncserver restart will not close the VNC connection. use vncserver-kill: 2
This article is from the "kras-linux" blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.