How to set up VNC on CentOS
Q I've installed a minimal CentOS 4 installation on a headless PC at home, which I plan to use for email, DNS, web hosting etc. I'm relatively new to Linux and really like the X-based system-config-tools that Red Hat has provided for system administration. I've read about VNC and have installed the vnc-server RPM but cannot get Vncserver to run. Can you please offer some insight to assist me in getting VNC up and running?
A Installing Vncserver on CentOS/RHEL is straightforward, but it does require a few other packages to operate correctly. Provided you're running a minimal install, the first step is to install vnc-server, xorg-x11, gnome-session and gnome-terminal. The xorg-x11 and gnome-session packages have numerous dependencies, so if you're installing via Yum and you have a slow internet connection, now would be a great time to go grab a coffee. Alternatively, you can avoid installing the Gnome-related packages and use the default TWM window manager. This will need xorg-x11-twm. If you do choose to use TWM, you can leave ~/.vnc/xstartup with the default configuration. If you plan to use Gnome, you can use the following:
vncconfig -iconic &
Once that's been saved, ensure that xstartup is executable. Finally, to start the VNC server, use the vncserver command. This will first ask for a password to use when you connect with your VNC client. If you do not specify a display for Vncserver to use, it will default to the first available display number (which is usually :1). You should now be able to use your VNC viewer to connect to your IP followed by display number (ie 192.168.1.10:1 for example). To get Vncserver to start at boot, use the chkconfig command to enable the service to start in the default runlevel. Additionally, on Centos/RHEL there is a Sysconfig file for Vncserver, located in /etc/sysconfig. This file is used to tell Vncserver which user to run under and which display to connect to.
Follow us on Identi.ca or Twitter