Followers

Monday 21 July 2014

Update PHP 5.4 with other repo.

How about default?

For example, look at PHP version.
CentOS
$ yum info php

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sin3.sg.voxel.net
 * extras: mirrors.sin3.sg.voxel.net
 * updates: mirror.neu.edu.cn
Available Packages
Name        : php
Arch        : x86_64
Version     : 5.3.3
Release     : 23.el6_4
Size        : 1.1 M
Repo        : updates
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated webpages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            :
            : The php package contains the module which adds support for the PHP
            : language to Apache HTTP Server.
It’s 5.3 you know.

Add repository

There are a few popular repository for CentOS like bellow.
  • epel
  • remi
  • rpmforge
Let’s install them.
you need to do it with root privilege so use sudo or su - and get privilege.

epel

CentOS
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

remi

CentOS
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

rpmforge

CentOS
# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Check repository

CentOS
# yum repolist
you can find the repository names you installed.

Enable repository and Install

These repository is not supported by CentOS, so for dependancy enable them only when you want to get special package.

CentOS
# vi /etc/yum.repos.d/epel.repo
/etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=0 # 1 -> 0 disable
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
CentOS
# vim /etc/yum.repos.d/rpmforge.repo
/etc/yum.repos.d/rpmforge.repo
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0 # 1 -> 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
setting them explicitly with option, you can use.
try to get information about php
CentOS
# yum --enablerepo=epel,remi,rpmforge info php

Name        : php
Arch        : x86_64
Version     : 5.4.22
Release     : 1.el6.remi
Size        : 2.7 M
Repo        : remi
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated web pages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            :
            : The php package contains the module (often referred to as mod_php)
            : which adds support for the PHP language to Apache HTTP Server.
OK, Let’s go on.
CentOS
# yum --enablerepo=epel,remi,rpmforge install php php-mysql php-devel
and install MySQL.
CentOS
# yum --enablerepo=epel,remi,rpmforge install mysql-server mysql-devel

Initialise

along with php, apache web server is installed automatically.if you type php -v, you can confirm it is installed but start web server and check it. because it’s very easy.
CentOS
# service httpd start
CentOS
# echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo.php
Open a browser in host and type IP address you set. (ex, 192.168.56.10/phpinfo.php or centos that I set before)
Can you see this screen in your browser?
phpinfo
OK next setup MySQL
CentOS
# service mysqld start
CentOS
$ mysql_secure_installation
configure charcter set to UTF-8
CentOS
# vim /etc/my.cnf
/etc/my.cnf
[mysqld]
.
.
#add bellow
character-set-server = utf8
skip-character-set-client-handshake
After change config file, do restart.
CentOS
# service mysqld restart
Login and confirm setting.
CentOS
$ mysql -u root -p
Enter password: # while mysql_secure_installation you set password you know
MySQL
mysql> staus
.
.
# check them like this
Server characterset: utf8
Db     characterset: utf8
Client characterset: utf8
Conn.  characterset: utf8

Done

 Source: http://webees.me/how-to-install-php-5-4-and-mysql-5-5-in-centos-6-4-via-yum/

Wednesday 4 December 2013

Mount ntfs partition on CentOS 6

1. open the terminal window with the root account.

2. download rpmforge for centos 6 to your system:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

3. now install the rpmforge for centos 6:

rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

4. just install/update the package fuse-ntfs-3g:

# yum update fuse-ntfs-3g

5. mount your units:

# yum install fuse-ntfs-3g

Sunday 12 May 2013

Install PHP Mcrypt extension on RHEL 6

Install PHP Mcrypt extension on RHEL 6

The php-mcrypt extension is not available on Redhat Enterprise Linux 6 although some applications such as Magento or phpMyAdmin require it to work properly.
We can easily install it though from the Fedora Project repositories.
1. Download the following RPM pacakges:
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/php-mcrypt-5.3.3-1.el6.x86_64.rpm
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
2. Install them using YUM:
yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm
3. Reload Apache server to load the extension up:
# service httpd restart
 
 
Source: http://injustfiveminutes.wordpress.com/2012/11/23/install-php-mcrypt-extension-on-rhel-6/ 

Sunday 21 April 2013

How to install your own VPN server in 5 mins (PPTP on CentOS, RedHat and Ubuntu)

Virtual Private Network (VPN) is the most effective way to bypass access control, the censorship, and network spying. It is also a safe way to connect to the internet to protect your privacy. It is usually better than using web proxy.
For example,  when you are on a business visit to Asia, very likely,  you are not able to access your Hulu Plus contents, or Amazon Prime unless you use a VPN connection to a server located in US. The reason is that Hulu or Amazon is only allowed to stream videos in US per license agreement with copyright holders.
Of course, there are many VPN providers. But if you want full control or want to  share the vpn with your buddies, you can get a server and install it by yourself.
Before you start, you need get a dedicated server with root access. VPS may not work well depending on the virtualization software used. You can get a cheap dedicated server with less than $50/month.
There are mainly 3 types of VPN servers: Point-to-Point Tunneling Protocol (PPTP), Layer 2 Tunneling Protocol (L2TP) and OpenVPN. In this tutorial, we use PPTP because it is supported natively on almost all devices, Windows, Linux, Android, IOS and Mac OS.
Step 1. Install PPTPD
If your OS is CentOS/RedHat 5:
yum install ppp
cd /usr/local/src
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.x86_64.rpm
rpm -Uhv pptpd-1.3.4-2.rhel5.x86_64.rpm
If your OS is CentOS/RedHat 6:
yum install ppp
cd /usr/local/src
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpm
rpm -Uhv pptpd-1.3.4-2.el6.x86_64.rpm
If you are using Ubuntu:
apt-get install pptpd
Step 2. Edit IP setttings in /etc/pptpd.conf
vi /etc/pptpd.conf
localip 192.168.0.1
remoteip 192.168.0.101-200
Step 3. Add user account in/etc/ppp/chap-secrets (assign username and password)
vi /etc/ppp/chap-secrets
usernameForuser1 *  setpassword1here  *
usernameForuser2 *  setpassword2here  *
Step 4. Optional settings in /etc/ppp/options.pptpd
vi /etc/ppp/options.pptpd
ms-dns 8.8.8.8
ms-dns 4.4.4.4
Step 5. Enable network forwarding in /etc/sysctl.conf
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
use the following command to apply the change:
sysctl -p
Step 6. Configure firewall
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -i eth0 -p gre -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT
service iptables save
service iptables restart
If you are using CSF firewall, you may refer to this post on firewall settings.
Step 7. Start PPTP VPN server
If your OS is CentOS or Redhat, using the following command:
service pptpd restart
To start PPTP Daemon automatically when rebooting next time, use command:
chkconfig pptpd on

If your OS is Ubuntu, you just reboot your machine.
Now you can test the VPN server from any client: Windows PCs, Linux PCs, Android phones/tablets, or iPhone and iPad.
The log of the VPN server, by default, is combined with system log located at /var/log/messages.

Source: http://freehostinganswers.com/blog/how-to-install-your-own-vpn-server-in-5-mins-pptp-on-centos-redhat-and-ubuntu/

Saturday 20 April 2013

Centos 6 Yum Update Error:- Requires: python(abi) = 2.4

Centos 6 Yum Update Error:-  Requires: python(abi) = 2.4

The error message indicates yum is trying to install from the repoforge el5 repository instead of el6. This needs to be corrected.
Here is the solution for this problem:-
solution :- reinstall rpmforge
go to terminal
01.
[root@gts250 rajiv]# su
02.
[root@gts250 rajiv]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
03.
[root@gts250 rajiv]# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

04.
[root@gts250 rajiv]# yum clean all
05.
[root@gts250 rajiv]# yum update

Source: http://rajivpandit.wordpress.com/2013/03/16/centos-6-yum-update-error-requires-pythonabi-2/

Friday 19 April 2013

VNC ( Virtual Network Computing )

VNC is used to display an X windows session running on another computer. Unlike a remote X connection, the xserver is running on the remote computer, not on your local workstation. Your workstation ( Linux or Windows ) is only displaying a copy of the display ( real or virtual ) that is running on the remote machine.
There are several ways to configure the vnc server. This HOWTO shows you how to configure VNC using the 'vncserver' service as supplied by CentOS.

1. Installing the required packages

The server package is called 'vnc-server'. Run the command: rpm -q vnc-server
The result will be either package vnc-server is not installed or something like vnc-server-4.0-11.el4.
If the server is not installed, install it with the command: yum install vnc-server
The client program is 'vnc'. You can use the command: yum install vnc to install the client if: rpm -q vnc shows that it is not already installed.
Make sure to install a window manager in order to get a full-featured GUI desktop. You can use the command yum groupinstall "GNOME Desktop Environment" to install the Gnome Desktop and requirements, for example. Other popular desktop environments are "KDE" and "XFCE-4.4". XFCE is more light-weight than Gnome or KDE and available from the "extras" repository.
If you are a minimalist, or simply testing, however, it is sufficient to have yum install a simple XTERM client: yum install xterm
<!> If you are running CentOS 6, the command is yum groupinstall Desktop
<!> If you are running CentOS 5, yum groupinstall "GNOME Desktop Environment" may complain about a missing libgaim.so.0. This is a known bug. Please see CentOS-5 FAQ for details.
<!> If you are running CentOS 6, the server is: tigervnc-server not: vnc-server

2. Configuring un-encrypted VNC

We will be setting up VNC for 3 users. These will be 'larry', 'moe', and 'curly'
You will perform the following steps to configure your VNC server:
  1. Create the VNC users accounts.
  2. Edit the server configuration.
  3. Set your users' VNC passwords.
  4. Confirm that the vncserver will start and stop cleanly.
  5. Create and customize xstartup scripts.
  6. Amend the iptables.
  7. Start the VNC service.
  8. Test each VNC user.
  9. Additional optional enhancements

2.1. Create the VNC user accounts

As root:
$ su -
# useradd larry
# useradd moe
# useradd curly
# passwd larry
# passwd moe
# passwd curly

2.2. Edit the server configuration

Edit /etc/sysconfig/vncservers, and add the following to the end of the file.
VNCSERVERS="1:larry 2:moe 3:curly"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 640x480"
VNCSERVERARGS[3]="-geometry 800x600"
Larry will have a 640 by 480 screen, as will Moe. Curly will have an 800 by 600 screen.
Note: This step is NOT out of sequence, but is placed here so that the next following step will fall adjacent to the step in which failure to perform it, will permit immediate fault diagnosis.

2.3. Set your users' VNC passwords

Switch user into the account for each user, and as noted below, run: vncpasswd This will create the ~/.vnc directory for that userid:
[~]# su - larry
[~]$ vncpasswd
[~]$ cd .vnc
[.vnc]$ ls
passwd
[.vnc]$ exit
[~]#

2.4. Confirm that the vncserver will start and stop cleanly

We will create the xstartup scripts by starting and stopping the vncserver as root. We also enable the vncserver service to be automatically started.
# /sbin/service   vncserver start
# /sbin/service   vncserver stop
# /sbin/chkconfig vncserver on
Note: if you omitted the preceding step of logging in as each configured user, and creating their ~/.vnc/ subdirectory, this test will fail.

2.5. Create xstartup scripts ( You may omit this step for CentOS 6 )

Login to each user and edit the xstartup script. To use Larry as an example, first login as larry
[~]$ cd .vnc
[.vnc] ls
mymachine.localnet:1.log  passwd  xstartup
Edit ~/.vnc/xstartup for each user. The original should appear as follows:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
Add the line indicated below to assure that an xterm is always present, and uncomment the two lines as directed if you wish to run the user's normal desktop window manager in the VNC. Note that in the likely reduced resolution and color depth of a VNC window the full desktop will be rather cramped and a look bit odd. If you do not uncomment the two lines you will get a gray speckled background to the VNC window.
#!/bin/sh
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

2.6. Amend the iptables

The iptables rules in /etc/sysconfig/ need to be amended to open the VNC ports; as needed, if a local ipv6 setup is being used, those need to be amended as well:
[root@xen-221 sysconfig]# cat iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth1 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@xen-221 sysconfig]#         
... and then restart the iptables:
# /sbin/service iptables restart

2.7. Start the VNC server

Start the vncserver as root.
# /sbin/service vncserver start

2.8. Test each VNC user

2.8.1. Testing with a java enabled browser

Let us assume that mymachine has an IP address of 192.168.0.10. The URL to connect to each of the users will be:
Larry is http://192.168.0.10:5801
Moe   is http://192.168.0.10:5802
Curly is http://192.168.0.10:5803
Connect to http://192.168.0.10:5801. A java applet window will pop-up showing a connection to your machine at port 1. Click the [ok] button. Enter larry's VNC password, and a 640x480 window should open using the default window manager selected for larry . The above ports  5801, 5802 and 5803  must be open in the firewall {iptables) for the source IP addresses or subnets of a given client.

2.8.2. Testing with a vnc client

For Larry: vncviewer 192.168.0.10:1
For   Moe: vncviewer 192.168.0.10:2
For Curly: vncviewer 192.168.0.10:3
To test larry using vncviewer, vncviewer 192.168.0.10:1 An authentication box will pop up, and you may enter Larry's VNC password. Once authenticated, a 640x480 window should open using Larry's default window manager. The vncviewer client will connect to port 590X where X is an offset of 1,2,3 for Larry, Moe, and Curly respectively, so these ports must be open in the firewall for the IP addresses or subnets of the clients.
If your local account userid is not, say, larry, you may 'switch user' for purposes of vncviewer thus:
export USER=larry ; vncviewer 192.168.0.10:1 
which has the effect of passing the username larry to the vncviewer program.

2.8.3. Starting vncserver at boot

To start vncserver at boot, enter the command:
/sbin/chkconfig vncserver on 
For basic VNC configuration the procedure is now complete. The following sections are optional refinements to enhance security and functionality.

3. VNC encrypted through an ssh tunnel

You will be connecting through an ssh tunnel. You will need to be able to ssh to a user on the machine. For this example, the user on the vncserver machine is: larry That account username needs to exist on the target machine, and either password, or keyed ssh access needs to be functional. the vncserver will also prompt for the vncpassword. The Linux and VNC system usernames and passwords are not required to be identical and are 'not' automatically synchronized. That is, remote users able and baker may each have differing credentials to set up the ssh tunnel to the remote VNC server, but if each uses the larry account, they will use the same VNC password.
  1. Edit /etc/sysconfig/vncservers and add the option -localhost
    VNCSERVERS="1:larry 2:moe 3:curly"
    VNCSERVERARGS[1]="-geometry 640x480 -localhost"
    VNCSERVERARGS[2]="-geometry 640x480 -localhost"
    VNCSERVERARGS[1]="-geometry 800x600 -localhost"
    
  2. /sbin/service vncserver restart
  3. Go to another machine with vncserver and test the VNC.
    1. vncviewer -via larry@192.168.0.10 localhost:1
    2. vncviewer -via moe@192.168.0.10 localhost:2
    3. vncviewer -via curly@192.168.0.10 localhost:3
By default, many vncviewers will disable compression options for what it thinks is a "local" connection. Make sure to check with the vncviewer man page to enable/force compression. If not, performance may be very poor!

4. Recovery from a logout ( Not implemented for CentOS 6 )

If you logout of your desktop manager, it is gone!
  • We added a line to xstartup to give us an xterm where we can restart our window manager.
    • For gnome, enter gnome-session.
    • For kde, enter startkde.

5. Remote login with vnc-ltsp-config

To allow remote login access via a vnc-client to the Centos system, the RPM packages named vnc-ltsp-config and xinetd can be installed. When a vnc-client connects to one of the configured ports, the user will be given a login screen. The sessions will *not* be persistent. When a user logs out, the session is gone.
The rpm package vnc-ltsp-config is easily installed via the EPEL repository noted in Available Repositories
Note: There are no major dependencies for the package so the vnc-ltsp-config*.rpm could easily be downloaded and installed without the need for enabling the EPEL repository.
Install, as root via:
# yum install xinetd vnc-ltsp-config
# /sbin/chkconfig xinetd on
# /sbin/chkconfig vncts on
# /sbin/service xinetd restart
Next, as root edit the file "/etc/gdm/custom.conf".
  • To the next blank line below the "[security]" section add "DisallowTCP=false"
  • To the next blank line below the "[xdmcp]" section add "Enable=true"
  • Make sure you are in a position to either run "gdm-restart" for default Gnome installs or just reboot the CentOS box.
This will add the ability to get the following default vnc-client based session connections:
resolution
color-depth
port
1024x768
16
5900/tcp
800x600
16
5901/tcp
640x480
16
5902/tcp
1024x768
8
5903/tcp
800x600
8
5904/tcp
640x480
8
5905/tcp
If you don't like the above defaults, just modify /etc/xinetd.d/vncts as required.
A major advantage of using the vnc-ltsp-config setup is the reduction of system resource utilization compared to the standard "per-user setup". No user processes will be started or memory consumed until a user actually logs into the system. Also, no pre-thought for user setup is needed (eg skip all of the manual individual user setup for vnc-server). The downside to the vnc-ltsp-config setup is that *any* user with the ability to login will likely have the ability to log into the system via a vnc-client with full gui unless steps are taken to limit that type of access. Also, there is no session persistance! Once the vnc-client closes, the vnc-ltsp-config session will terminate (by default) and all running processes will be killed.
This option can be combined with ssh tunnelling using a slightly modified version of the "vncviewer -via" command noted above:
vncviewer -via remoteUser@remoteHost localhost:vncSinglePortNumber
For the default vnc-ltsp-config install, the "vncSinglePortNumber" is the last digit only of the port number. Port 5900 (1024x768 16bit) would just be "0", for example.
Note: you will need to be aware of possible interaction issues if you enable either selinux or iptables. If you are not running a display manager (runlevel 3 for example), you will need to start one or you will only get a black screen when you connect.

6. VNC-Server for an already logged in GUI console session - 2 options

Often you will need remote access to an already logged in GUI session on a "real" console. Or you will need to help another user remotely with an GUI or visual issue. You will need either "vnc-server" or "x11vnc". The vnc-server option will be a module added to X11 for "allways on" vnc support, while x11vnc will allow for adhoc vnc support.
vnc-server install will require no third party repos or source building.
x11vnc is a way to view remotely and interact with real X displays (i.e. a display corresponding to a physical monitor, keyboard, and mouse) with any VNC viewer. In this way it plays the role for Unix/X11 that WinVNC plays for Windows.

6.1. x11vnc adhoc option

Karl Runge has generously provide a exceptional amount of information at http://www.karlrunge.com/x11vnc/ for x11vnc. There is info on securing the connection and also an "Enhanced TightVNC Viewer (ssvnc)". To make it easy, follow these steps:
1. Download the latest rpm install from http://dag.wieers.com/rpm/packages/x11vnc/ to the host you want the vnc-client to connect to:
wget http://dag.wieers.com/rpm/packages/x11vnc/x11vnc-0.9.3-1.el5.rf.i386.rpm
2. Install, as root, via the yum or rpm programs on the host you want the vnc-client to connect to:
yum install x11vnc-0.9.3-1.el5.rf.i386.rpm
3. Start the x11vnc process on the host you want the vnc-client to connect to. Please take a long look at the possible options from the x11vnc website. A very simple/insecure example for a trusted network setup (local network or VPN) is to have the user with the GUI console issue the command:
[user@helpme_host ~$] x11vnc -nopw -display :0.0
Then connect (without password) via a vnc-client to the IP/hostname and port noted by the x11vnc command. By default, x11vnc will allow connections from all interfaces. Host based firewall settings may need to be modified.
You can combine this with ssh tunneling:
ssh -C -t -L 5900:localhost:5900 [remote ip] 'x11vnc -usepw -localhost -display :0'
Note that the -C flag is for compression, so may not be required

6.2. vnc-server X11 "always on" option

1. On the the system you want to run vnc-server, install vnc-server as noted above.
2. Edit /etc/X11/xorg.conf, as root, and add/create a 'Module' Section and add 'Load "vnc"':
Section "Module"
  Load "vnc"
EndSection
3. For standard vnc authentication, edit /etc/X11/xorg.conf, as root, and add to the 'Screen' Section:
 Option "SecurityTypes" "VncAuth"
  Option "UserPasswdVerifier" "VncAuth"
  Option "PasswordFile" "/root/.vnc/passwd"
4. As root, run 'vncpasswd" to create the password noted above.
5. Restart X11 (<Ctrl>+<Alt>+<BS> will work if on the console already)
6. You should be able to connect with a vncviewer client as normal.
7. To trouble shoot, check for errors in the /var/log/Xorg.0.log or verify that iptables or selinux is not interfering with remote connections. Additional information is at http://www.realvnc.com/products/free/4.1/x0.html

Source: http://wiki.centos.org/HowTos/VNC-Server

How to install VNC server on CentOS 6

VNC is a protocol that is used to share the desktop with other users/computers over the network/Internet.In order to share a desktop, VNC server must be install and configure on the computer and VNC client must be run on the computer that will access the shared desktop.
When we install the minimal copy of CentOS Server, it only gives us the “Command Line” interface.

But some people prefer GUI instead and for this they install Full version of Gnome on CentOS. Actually there is a better way and that is to install VNC. VNC provides a lightweight virtual desktop than full blown version of Gnome.
To run the VNC Server on CentOS, we have to install these required packages:
sudo yum groupinstall Desktop

sudo yum install tigervnc-server

sudo yum install xorg-x11-fonts-Type1

This is optional:
sudo yum install vnc

To start VNC Server on boot
sudo chkconfig vncserver on

To setup users’ VNC password:
vncpasswd

Edit the /etc/sysconfig/vncservers file:
sudo nano /etc/sysconfig/vncservers

Add the following to the end of the file:
VNCSERVERS="1:arbab"
VNCSERVERARGS[1]="-geometry 1024x600"

The iptables rules need to be amended to open the VNC ports:
sudo iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
sudo service iptables save
sudo service iptables restart

Restart the VNC Server:
sudo service vncserver restart

Now kill the VNC Server:
vncserver -kill :1

Edit the xstartup file in .vnc directory:
nano .vnc/xstartup

Comment the last line and run the Gnome:
#twm & 
exec gnome-session &

Restart the service:
sudo service vncserver restart

Now, download VNCViewer onto our desktop computer from which we want to access the shared desktop. Connect using ServerIP/Name:1 (:1 is for the VNC server window), In my case it is centos:1.

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server.

Ability to connect for multiple users:
Create a local user, using the following command:
sudo adduser ali

Create a password for newly created user:
sudo passwd ali

Switch to the newly created user and run vncpasswd command for it:
su ali
vncpasswd

Edit the /etc/sysconfig/vncservers file:
sudo nano /etc/sysconfig/vncservers

Add these lines for new user:
VNCSERVERS="1:arbab 2:ali"
VNCSERVERARGS[1]="-geometry 1024x600"
VNCSERVERARGS[2]="-geometry 1024x600"

Restart the VNC service:
sudo service vncserver restart

Kill the vncserver session for new user and edit the xstartup file:
su ali
vncserver -kill :2
cd ~
nano .vnc/xstartup

Modify the file so it looks like this:
#twm & 
exec gnome-session &

Restart the VNC service:
sudo service vncserver restart

Connect with newly created user using centos:2, Where centos is my server name:

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server for newly created user.

Hope this will help you!

Source: http://rbgeek.wordpress.com/2012/06/26/how-to-install-vnc-server-on-centos-6/