Archive for the ‘Linux application Installations’ Category

Custom TLD for local network

November 19, 2013 Leave a comment



In this post I will mention the steps to setup a TLD ( top level domain ) which can be used in a local network. Even though I have configured dns zones manually, this was the first time I configured a TLD zone(eventhough local one) of my own and it felt really cool after completing the setup 🙂



1) TLD used: “.jackal”
2) Bind version: 9
3) OS: Debian 7 (wheezy)
4) DNS/Nameserver ip:



1) Install bind and required packages,

apt-get install bind9 dnsutils


2) Insert the following into file “/etc/bind/named.conf.default-zones”,

zone "jackal." {
        type master;
        file "/etc/bind/db.jackal";
        allow-transfer { any;};
        allow-query { any;};


3) Verify configuration,

root@dns01:~# named-checkconf 


4) Create the zone file for “jackal.” in “/etc/bind/db.jackal”

; BIND data file for TLD ".jackal"
$TTL	604800
@	IN	SOA	jackal. root.jackal. (
			      2		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
@	  IN	NS	ns1.jackal.
@	  IN	NS	ns2.jackal.
@	  IN	A
dns01	  IN 	A
apache01  IN	A
mysql01   IN	A
postfix01 IN	A
dovecot01 IN	A
ns1	  IN	A
ns2	  IN	A


5) And verify the zone file, bind configuration and after that restart bind service.

root@dns01:/etc/bind# named-checkzone jackal. db.jackal 
zone jackal/IN: loaded serial 2
root@dns01:/etc/bind# named-checkconf 
root@dns01:/etc/bind# service bind9 restart
[....] Stopping domain name service...: bind9waiting for pid 2279 to die
. ok 
[ ok ] Starting domain name service...: bind9.


6) Create a separate directory for storing zone files of domains,

mkdir /etc/bind/zones/


7) Use the “” script for creating dns zone entries.
NOTE: We are using TLD’s ending with “.jackal”. Also customize the “” for your own use 😀

root@dns01:/# ./ rogerjo.jackal
[*] Created zone file for rogerjo.jackal
[*] Added zone entry for rogerjo.jackal in bind configuration
root@dns01:/# named-checkzone rogerjo.jackal /etc/bind/zones/rogerjo.jackal 
zone rogerjo.jackal/IN: loaded serial 1378789827
root@dns01:/# rndc reload
server reload successful


if [ $# -ne 1 ];then
	echo "Usage: "
	exit 1

## Domain name

if [ `sed -n '/^zone "'${MYDOMAIN}'."/p' ${ZONECONFIG}|wc -l` -eq 1 ];then
	echo "[ERROR] Entry for ${MYDOMAIN} already exists"
	exit 1

## Nameservers

## Apache and ftp service are running on the same host

##Mail server

## DB Server

## Create zone file
cat > /etc/bind/zones/${MYDOMAIN} << EOF \$TTL    86400 @       IN      SOA     ns.${MYDOMAIN}. root.${MYDOMAIN}. (                         1378789827      ; Serial                         10800   ; Refresh                         3600    ; Retry                         604800  ; Expire                         10800 ) ; Minimum ${MYDOMAIN}.       IN NS   ${NAMESERVER1}. ${MYDOMAIN}.       IN NS   ${NAMESERVER2}. ${MYDOMAIN}.       IN A    ${APACHE_IP} www.${MYDOMAIN}.   IN CNAME ${MYDOMAIN}. ${MYDOMAIN}.       IN MX  10  mx01.${MYDOMAIN}. ${MYDOMAIN}.       IN MX  10  mx02.${MYDOMAIN}. mx01.${MYDOMAIN}.  IN A	   ${SMTP_IP} mx02.${MYDOMAIN}.  IN A	   ${SMTP_IP} pop.${MYDOMAIN}.   IN A    ${POP_IMAP_IP} imap.${MYDOMAIN}.  IN A    ${POP_IMAP_IP} mysql.${MYDOMAIN}. IN A	   ${MYSQL_IP} ftp.${MYDOMAIN}.   IN A	   ${FTP_IP} EOF echo "[*] Created zone file for ${MYDOMAIN}" ## Create zone entry in bind configuration cat >> ${ZONECONFIG} << EOF

zone "${MYDOMAIN}." {
  	type master;
	file "/etc/bind/zones/${MYDOMAIN}";

echo "[*] Added zone entry for ${MYDOMAIN} in bind configuration"


if [ $# -ne 1 ];then
	echo "Usage: <domainname>"
	exit 1

## Domain name


if [ `sed -n '/^zone "'${DOMAIN}'."/p' /etc/bind/named.conf.default-zones|wc -l` -eq 1 ];then
	##Remove entries from dns configuration file
	sed -i -e '/^zone "'${DOMAIN}'."/,/^};/d' ${ZONECONFIG}
	sed -i '$d' ${ZONECONFIG}

	echo "[*] Removed zone entries from bind configuration"
	echo "[ERROR] ${DOMAIN} not present in bind configuration"
	exit 1

#Remove zone file if it exists
if [ -f /etc/bind/zones/${DOMAIN} ];then
	rm -f /etc/bind/zones/${DOMAIN}
	echo "[*] Removed zone db file"

Sync svn repo commits to website documentroot in Cpanel Server

June 8, 2013 Leave a comment


SITUATION: Customer has a cpanel server with one domain hosted on a shared ip and wants to setup svn repository for this domain in such a way that whenever the svn commit operation takes place, the contents of the repository is exported to the documentroot. Thus all updates to files inside documentroot can be done over svn instead of via ftp. Also use ‘svnserve’ daemon for setup and don’t use ‘mod_dav’.


1) Cpanel Server is used.
2) Domain is setup on a shared ip
3) Suphp is the php handler used
4) ‘username’ is the username of the website



1) Install subversion in cpanel server

yum install subversion.x86_64 -y

2) Create a directory named ‘repos’ inside the default documentroot of apache(ie, /usr/local/apache/htdocs/) and start the ‘svnserve’ daemon from that directory. Also make sure that the port 3690 is opened in firewall and you are starting the service as root user.

mkdir /usr/local/apache/htdocs/repos
svnserve -d -r /usr/local/apache/htdocs/repos

3) Create a repository named ‘username’ and import its home directory(/home/username/public_html) to the repository,

cd /usr/local/apache/htdocs/repos
svnadmin create username
cd ~
svn import /home/username/public_html file:///usr/local/apache/htdocs/repos/username -m "username"

4) Now open up the svn repository configuration file “/usr/local/apache/htdocs/repos/username/conf/svnserve.conf” and disable anonymous access and specify the user authentication and authorization files,

anon-access = none
auth-access = write

password-db = /usr/local/apache/htdocs/repos/username/conf/passwd
authz-db = /usr/local/apache/htdocs/repos/username/conf/authz
realm = Project
logfile = /tmp/svn.log

5) Create a new user in user database file “/usr/local/apache/htdocs/repos/username/conf/passwd”

jackal777 = pnity29#@I

6) Set authorization for user created in password file via “/usr/local/apache/htdocs/repos/username/conf/authz”

jackal777 = rw

7) Now finally create post commit hook inside the repository directory “/usr/local/apache/htdocs/repos/username/hooks/post-commit” and set execute permission for that file. Paste the following contents to that file,

svn export --force file:///usr/local/apache/htdocs/repos/username/ /home/username/public_html/
chown -R username:username /home/username/public_html/

The post commit script will export the contents of the repository to the website documentroot and assigns the proper permission to the directory.




Now checkout the repository to your local directory,

svn co svn:// --username=jackal777

Make modifications with the files and then commit to the repository,

cd username
svn commit

Now login to the server and check whether the commit made to repository are shown inside “/home/username/public_html”.

That’s it 🙂

Apache proxy redirect

June 7, 2013 1 comment

SITUATION: Customer has a single website with four different web applications installed under four sub directories of the website. Now configure apache to serve all these four applications from four different ports.


1) OS – Ubuntu 11

2) Website name and documentroot,


DocumentRoot:  /home/jackal/public_html

3) Web application sub-directories and the ports going to be used,

/home/jackal/public_html/app1 : Port 7001
/home/jackal/public_html/app2 : Port 7002
/home/jackal/public_html/app3 : Port 7003
/home/jackal/public_html/app4 : Port 7004

4) Apache mod_proxy module is installed. You can install it using,

apt-get install libapache2-mod-proxy-html -y


1) Open up /etc/apache2/ports.conf and add the following directives,

Listen 80

2) Enable mod_proxy by copying the configuratons from ‘mods-available’ directory to ‘mods-enabled’

cp -pr /etc/apache2/mods-available/*proxy* /etc/apache2/mods-enabled/

3) Create a virtualhost file “/etc/apache2/sites-enabled/” for website with the following contents,

<VirtualHost *:80>
DocumentRoot /home/jackal/public_html

ProxyPass /app1/
ProxyPass /app2/
ProxyPass /app3/
ProxyPass /app4/


DocumentRoot /home/jackal/public_html/app1

DocumentRoot /home/jackal/public_html/app2

DocumentRoot /home/jackal/public_html/app3

DocumentRoot /home/jackal/public_html/app4

4) Test configuration and gracefully restart apache.

apache2ctl -t
apache2ctl -k graceful

5) Now access the url’s,


SCOPE: Using mod_proxy, we could forward requests coming to different servers and make the applications running from several different servers.


Hope this info will be somewhat useful 🙂

Installing JBoss AS 7.0 on Centos 5

August 22, 2012 Leave a comment



TASK: Install JBoss AS 7.0 on Centos 5


Dependencies: JBoss AS 7.0 requires Oracle java >= 1.6.0 and Maven >= 3.0.0




1) Download Oracle Java and Maven for your system architecture,


cd /opt
lynx ""
tar xzf jdk-7u6-linux-x64.tar.gz
mv jdk1.7.0_06 /usr/lib/java-1.7.0_06
tar xzf apache-maven-3.0.4-bin.tar.gz
cd apache-maven-3.0.4



2) Add the required environment variables in your /etc/profile system file at the bottom,




After adding the above run the command,

source /etc/profile


3) Download JBoss AS 7.0 and change the local host ip address in the configuration to your public ip and start JBoss,


lynx ""
tar xzf jboss-as-web-7.0.2.Final.tar.gz
replace "" "" -- jboss-as-web-7.0.2.Final/standalone/configuration/standalone.xml


After this you can access JBoss via url http://<Your server IP>:8080/”