How to Install and Configure X11 with Remote VNC Access on Centos 5

The instructions below will walk you through the process of installing the X window system, GNOME desktop environment, and configuring VNC so that you can access it remotely.

yum -y upgrade
yum -y groupinstall "GNOME Desktop Environment"
yum -y install vnc-server

As a general rule of thumb you should never run X windows as root. In this example we will add a system user with the username 'wkst' and configure X windows to run under that user.

adduser wkst

Next you need to set a password for the user wkst:

passwd wkst

Next we will drop down to the system user 'wkst' using su and configure VNC. When running the vncserver binary you will again be asked to set a password. This will be the password you use in your VNC client.

su wkst
vncserver

Next you need to edit /home/wkst/.vnc/xstartup and uncomment the following two lines:

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

Next we want to restart VNC so the changes take affect

vncserver -kill :1
vncserver

That's it, you can now connect to your server using the server IP address with a :1 (the display port) at the end of it using your VNC client.