Howto Install and Configure VNCserver in Linux?

January 5, 2012    |   Posted by admin   |    Category: Linux Administration

The common method to manage a Linux server remotely is through CLI interface via SSH, which many people often find it difficult as they are not familar with the Linux commands.

The solution is to install a KDE Or GNOME Desktop on the Linux server and access it through VNC. VNC (Virtual Network Computing) is a graphical desktop sharing system which allows you to share a desktop of a remote server as if you are sitting in front of it.

Following are the steps to install and configure VNC on a Linux server:

1. Install the vnc-server packages.

# yum install vnc*

2. Now, edit the file /etc/sysconfig/vncservers and add the following lines at the end:

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"

This will enable VNC on terminal 1 with 800×600 resolution.

3. Next step is to create a startup file in .vnc directory under the user’s home directory, in this case it is /root

# nano /root/.vnc/xstartup

4. Now, add the following in the file

###########################
#!/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" &
startkde &

#############################

The last line in the above file indicates that it will start the KDE desktop by default. To start the GNOME desktop, replace the last line with “exec gnome-session &”

5. Set execute permissions on the file:

# chmod 755 /root/.vnc/xstartup

6. Now set a vnc password for user ‘root’

# vncpasswd

7. Once done, start the vncserver and it should show something like below:

# vncserver
New 'server.hostname:1 (root)' desktop is server.hostname:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server.hostname:1.log

where, server.hostname above is your server’s hostname. The log file will be created under the .vnc directory of the users home directory. The Linux server side part is done.

8. Now, download and install VNC-Viewer on your computer (client-side). Open vnc-viewer and enter “server.hostname:1″ (use your server IP instead of server.hostname) and the vnc password you have set above. You will now be connected to the graphical interface of your Linux server.

error event.h: No such file or directory

December 19, 2011    |   Posted by admin   |    Category: Linux Administration

While compiling a package say, Greensql you may end up with the “event.h: No such file or directory”  error message as follows:

# make
g++ -g -Wno-deprecated -Wall -I/usr/local/include/
-c -o main.o main.cpp
main.cpp:23:19: error: event.h: No such file or directory

It indicates that the required ‘libevent’ package is missing from the server. You have to install the libevent and libevent-devel package either using YUM or from a RPM.

# yum install libevent libevent-devel

OR install the RPMs:

# rpm -ivh ftp://ftp.muug.mb.ca/mirror/centos/5.7/os/x86_64/\
CentOS/libevent-1.4.13-1.x86_64.rpm
# rpm -ivh ftp://ftp.muug.mb.ca/mirror/centos/5.7/os/x86_64/\
CentOS/libevent-devel-1.4.13-1.x86_64.rpm

(download the i386 version if you have a 32bit machine)

RPM remove error: specifies multiple packages

November 18, 2011    |   Posted by admin   |    Category: Linux Administration

You may receive an error message “error: packagename specifies multiple packages” while removing a package with “rpm -e package-name”, for example:

# rpm -e mysql-devel
error: "mysql-devel" specifies multiple packages

This is because the packages of both the architectures (32 and 64 bit) are installed  on the server i.e.

mysql-devel.i386
mysql-devel.x86_64

CentOS, Fedora will list the duplicate packages when you query them using RPM. It won’t list the architecture i.e.

# rpm -qa mysql-devel
mysql-devel
mysql-devel

To list the packages along with their architecture, use the –queryformat option while querying the package,

# rpm -q --queryformat "%{name}.%{arch}\n" mysql-devel
mysql-devel.i386
mysql-devel.x86_64

Now, remove the package you wish to, for example 32 bit package:

# rpm -e mysql-devel.i386
Comments Off

Nginx 502 Bad Gateway error

October 30, 2011    |   Posted by admin   |    Category: Linux Administration

My server went down today and after restarting, it came up with a “Nginx 502 Bad Gateway” message. At first I thought its something related to the Nginx service, so restarted the nginx service but immediately realized it wasn’t the case.

Nginx receives a request on port 80 and it then proxies the request to ‘localhost’ on port 8080 (in my case) where another service is configured on it. If no service is listening on port 8080, it results in a ‘Nginx 502 Bad gateway’ message. I immediately realized it was the Java service binded on port 8080 of my server and started it.

# java -jar /home/user/test.jar

The website was online immediately.

The Nginx proxy port is defined in the Nginx configuration file and different services could be binded to the proxy port depending on your setup. It could be

1) PHP-fpm
2) php_cgi
3) FastCGI

OR could be something else. You have to start the service listening on the proxy port to get your website/application online.

Howto: find the Linux kernel version?

September 2, 2011    |   Posted by admin   |    Category: Linux Administration

The ‘uname‘ command is use to determine certain system information in all the Linux/Unix flavours like CentOS, Ubuntu, Debian, Fedora, FreeBSD etc. With specific ‘uname’ options, you can display all the details of the current working kernel on the server.

To display the working kernel name, version, date and time, system architecture type etc, use:

# uname -a
Linux server.domain.tld 2.6.18-164.11.1.el5 #1
SMP Wed Jan 20 07:39:04 EST 2010 i686 i686 i386 GNU/Linux

To print only the kernel version along with it’s major and minor versions:

# uname -r
2.6.18-164.11.1.el5

To print the system architecture type i.e. whether the machine is 32 or 64 bit, use:

# uname -p
i686

The /proc/version file also contains the kernel information:

# cat /proc/version
Linux version 2.6.18-164.11.1.el5 (gcc version 4.1.2 20080704 
(Red Hat 4.1.2-46)) #1 SMP Wed Jan 20 07:39:04 EST 2010