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)

How to Install and Enable cPanel Proxy?

December 5, 2011    |   Posted by admin   |    Category: cPanel Management

cPanel, WHM and even Webmail uses non-common ports which some Internet Server Providers (ISP) do not allow and makes it impossible for people to access any of these. cPanel works on 2082/2083, WHM 2086/2087 and Webmail 2095/2096.

The workaround is to install cPanel Proxy which works as a proxy gateway for Apache and the requests to cPanel/WHM/Webmail are then served through port 80 instead of their respective ports which are blocked by the ISP.

Here’s how to Install cPanel Proxy:
——————————————————————————–
1. You have to recompile Apache with the cPanel proxy module.
a) You can either execute ‘/scripts/easyapache‘ script via SSH
OR
use WHM -> Software -> ‘EasyApache (Apache Update)‘ option.

b) On the next step, leave the current profile as it is and click ‘Start Customizing Based on Profile’

c) Click ‘Next Step’ in the Apache/PHP selection pages and goto the 5th step

d) On the Short Options List, click ‘Exhaustive Options List’ button to list all the Apache/PHP modules.

e) Scroll down a bit and select the “Proxy” module

f) Click ‘Save and Build‘ and proceed to build Apache with the Proxy module.

It may take around 30 minutes for the process to complete. Once the module is compiled, a VirtualHost entry for the cPanel/WHM/Webmail sub-domains is added in the Apache configuration file.

Here’s how to Enable cPanel Proxy for an Existing account:
——————————————————————————————————————————–

2)  The next step is to add ‘A’ records for cPanel/WHM/Webmail for the domain you need to enable proxy access on. To add the records,

a) Goto WHM ->  DNS Functions.

b) Click ‘Edit a DNS Zone’ option and select the domain to edit and click Edit.

c) Scroll down to the empty boxes and add the following records

cpanel 14400 IN A ServerIP
whm 14400 IN A ServerIP
webmail 14400 IN A ServerIP

where, ‘ServerIP’ is the actual IP of the server.

d) Click ‘Save’.

Once the records are added, allow sometime to propagate and then you should be able to access cPanel at, http://cpanel.yourdomain.tld. You will be able to access WHM/Webmail the same way.

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.