UnixServerAdmin

Server Administration & Management

“ffmpeg headers not found” error while installing ffmpeg in cPanel Servers

The error received is

checking for ffmpeg support… yes, shared
checking for ffmpeg headers… configure: error: ffmpeg headers not
found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option

This is due to missing header files in  “/usr/local/include/ffmpeg” directory.

Check whether the directory “/usr/local/include/ffmpeg” exists else create it.

# mkdir /usr/local/include/ffmpeg

The copy the header files.

# cp -p /usr/local/src/ffmpeg/libavformat/avio.h /usr/local/include/ffmpeg

# cp -p /usr/local/src/ffmpeg/libavformat/avformat.h /usr/local/include/ffmpeg

# cp -p /usr/local/src/ffmpeg/libavcodec/avcodec.h /usr/local/include/ffmpeg

You need to install your ffmpeg again. After installing the ffmpeg, install ffmpeg-php.

September 30, 2011 Posted by | FFMPEG | | Leave a comment

How to converting Audio & Videos using FFMPEG

1) This will convert video.mov to video.flv

# ffmpeg -i video.mov video.flv

2) Converting 3GP to FLV using FFMPEG

# ffmpeg -i video.3gp -sameq -an video.flv

This will convert video.3gp file to video.flv (Sound will be disaled in video.flv)

3) Converting Mpeg to FLV using FFMPEG

# ffmpeg -i video.mpeg video.flv

This will convert video.mpeg file to video.flv

4) Converting MPEG to 3GP using FFMPEG

# ffmpeg -i video.mpeg -ab 8.85k -acodec libamr_wb -ac 1 -ar 16000 -vcodec h263 -s qcif video.3gp

5) Converting AVI to FLV using FFMPEG

# ffmpeg -i video.avi -s 500×500 video.flv ( resolution of video.flv wil be  500×500)

6)Creating video thumbnails using ffmpeg

# ffmpeg  -itsoffset -4  -i video.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320×240 video.jpg

This command generates a 320×240 sized PNG thumbnail at the 4th second in the video.

Audio conversion:-

1) Converting WMV to FLV using FFMPEG

# ffmpeg -i audio.wmv audio.flv

This will convert audio.wmv file to audio.flv.

2) Converting AMR to MP3 using FFMPEG

# ffmpeg -i audio1.amr -ar 25050 audio1.mp3

This will convert audio.amr file to audio.mp3  with audio rate of  25.05 KHz

3)Converting WMV to MP3 using FFMPEG

# ffmpeg -i audio1.wmv audio1.mp3

This will convert audio1.wmv file to audio1.mp3

4) Converting aac to mp3 using FFMPEG

# ffmpeg -i audio1.aac -ar 25050 -ab 32 audio1.mp3

This will convert audio.aac to audio.mp3 with audio rate 25.05 KHz and Audio BitRate 32KHz

September 29, 2011 Posted by | FFMPEG | , | Leave a comment

How to install FFMPEG from source code and its modules

This post will provide you with the instructions to download and install ffmpeg, ffmpeg-php, flvtool, lame, mplayer, libogg, libvorbis, mencoder, and other codecs used with ffmpeg. This is used by most of your video sites and youtube clones for video streaming.

1. Create a new Directory under the src folder

# mkdir /usr/local/src/ffmpeg
# cd /usr/local/src/ffmpeg

2. Download all the Sources

# wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
# wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
# wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
# wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
# wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
# wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz

3. Uncompress all the source files

# bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar
# tar zxvf flvtool2_1.0.5_rc6.tgz
# tar zxvf lame-3.97.tar.gz
# bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar
# tar zxvf libogg-1.1.3.tar.gz
# tar zxvf libvorbis-1.1.2.tar.gz

4. Create the new codecs directory and move the codecs

# mkdir /usr/local/lib/codecs/
# mv essential-20061022/* /usr/local/lib/codecs/
# chmod -R 755 /usr/local/lib/codecs/

5. Install SVN and Ruby

# yum install subversion
# yum install ruby
# yum install ncurses-devel

6. Download the latest FFMPEG and Mplayer from the subversion

# svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

7. Compile LAME

# cd /usr/local/src/ffmpeg/lame-3.97
# ./configure
# make
# make install

8.Compile libOGG

# cd /usr/local/src/ffmpeg/libogg-1.1.3
# ./configure
# make
# make install

9.Compile libVorbis

# cd /usr/local/src/ffmpeg/libvorbis-1.1.2
# ./configure
# make
# make install

10.Compile flvtool2

# cd /usr/local/src/ffmpeg/flvtool2_1.0.5_rc6
# ruby setup.rb config
# ruby setup.rb setup
# ruby setup.rb install

11.Compile MPlayer

# cd /usr/local/src/ffmpeg/mplayer
# ./configure
# make
# make install

12.Compile FFMPEG

# cd /usr/local/src/ffmpeg/ffmpeg
# ./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared
# echo ‘#define HAVE_LRINTF 1? >> config.h
# make
# make install

13.Create symblinks

# ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
# ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
# ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
# ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
# ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51

14.Compile FFMPEG-PHP

# cd /usr/local/src/ffmpeg/ffmpeg-php-0.5.0
# phpize
# ./configure

——————————————————————-
There’s a small issue in this version of ffmpeg-php which, when “make” is run, will cause the following error:

gcc -I. -I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/local/src/ffmpeg-php-0.6.0/include -I/usr/local/src/ffmpeg-php-0.6.0/main -I/usr/local/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include/libavcodec/ -I/usr/local/include/libavformat/ -I/usr/local/include/libavutil/ -I/usr/local/include/libswscale/ -I/usr/local/include/libavfilter/ -I/usr/local/include/libavdevice/ -I/usr/include/php -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c -fPIC -DPIC -o .libs/ffmpeg_frame.o
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_toGDImage’:
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_ffmpeg_frame’:
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1

To correct this issue, we’ll update ffmpeg_frame.c and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

# vi ffmpeg_frame.c

:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32
:wq!
———————————————————————

Now we can proceed with compiling:

# make
# make install

15.Install FFMPEG-PHP (make sure the php.ini path is correct.)

Get correct php.ini path add the extesion ffmpeg.so Usually it is given as extension=ffmpeg.so and the extension_dir=/usr/local/lib/php/extensions/   Make sure that the ffmpeg.so is in /usr/local/lib/php/extensions/

# echo ‘extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’>> /usr/local/Zend/etc/php.ini

Or the best way is to check the path for extension_dir in php.ini Then locate the file ffmpeg.so. Copy the file ffmpeg.so to extension_dir and add the line extension=ffmpeg.so in php.ini

# vi /etc.php.ini
——————-
extension=ffmpeg.so
——————-

16.Restart Apache to load FFMPEG-PHP

# service httpd restart

17.Verify the installation

# php -r ‘phpinfo();’ | grep ffmpeg

If you get a few lines such as
———————————————————–
ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0
———————————————————–

Then everything is installed and working fine.

September 28, 2011 Posted by | FFMPEG | , | Leave a comment

MySQL error : Can’t create new tempfile: ‘*.TMD file

If you are getting Can’t create new tempfile: ‘tablesname.TMD file error while repairing corrupted database tables please try use following command to fix it

# myisamchk -r -f  tables.MYI

September 27, 2011 Posted by | MySQL | | Leave a comment

How to solved Open Office asking for document recovery everytime

Sometimes open office asking for document recovery every time ? if the document doesn’t exist then also ? If Yes, then follow this document to solve your problem. Here is following steps to solve the problem :-

For root user :-

1. Go to Terminal, type following command

# cd .openoffice.org/<version-of-openoffice>/user/registry/data/org/openoffice/Office/

# ls

Common.xcu  Histories.xcu  Linguistic.xcu  Recovery.xcu Views.xcu  Writer.xcu

There you will find Recovery.xcu; Remove Recovery.xcu  Now try to open it will not ask you for recovery.

# rm -rvf Recovery.xcu

For normal user :-

1. Go to Terminal, type following command

# cd /home/<user-name>/.openoffice.org/<version-of-openoffice>/user/registry/data/org/openoffice/Office/

# ls

Common.xcu  Histories.xcu  Linguistic.xcu  Recovery.xcu Views.xcu  Writer.xcu

There you will find Recovery.xcu; Remove Recovery.xcu Now try to open it will not ask you for recovery.

# rm -rvf Recovery.xcu

September 26, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How To Share Linux bash sessions

Sometimes it happens that we must give support to a colleague or a customer on a Linux machine. It’s very difficult to spell all bash command I will use to check which could be the problem, especially by phone. “screen” command is a solution about this problem. First install Screen.

# yum install screen

You should use screen by simply ask to the user you want to assist to type on the console the following command

# screen

So if you can connect to the machine (even with ssh) you should run the following command

# screen -x

to share the same bash session.

September 25, 2011 Posted by | Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to Disable or Block CD/DVD ROM Linux

Below procedure to disable or block CD/DVD on Linux

1) Go to Directory Where your kernel drivers stored. Follow exact command.

# cd /lib/modules/$(uname -r)/kernel/drivers/cdrom

2) Now list directory.

# ls

cdrom.ko

3) Now rename or delete cdrom.ko file with following command.

# mv cdrom.ko cdrom.ko-ok

To Delete file execute below command

# rm -rf cdrom.ko

4) Now reboot your computer and Insert CD or DVD into Drive. It will not detect.

5) If you dont want to reboot your computer then just execute below command.

# modprobe -r sr_mod

September 24, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to Set Java Home Directory & Path

1. Set JAVA_HOME & PATH for single user

Login to your account and open .bash_profile file:

# vi ~/.bash_profile

export JAVA_HOME=/usr/local/jdk1.6.0_27
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin

2. Set JAVA_HOME / PATH for All User

You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:

# vi /etc/profile
———————————————————————
#Set JAVA_HOME as follows using syntax
export JAVA_HOME=/usr/local/jdk1.6.0_27
#Set PATH as follows:
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin
———————————————————————

# which java

“OR”

Type following command to make soft links:

# ln -s /usr/local/jdk1.6.0_27/bin /usr/bin

# ln -s /usr/local/jdk1.6.0_27/bin/java /usr/bin/java

September 23, 2011 Posted by | Java, Tips & Tricks, Unix/Linux | , , , | Leave a comment

Channel Bonding – Points

arp_ip_target
Specifies the IP addresses to use as ARP monitoring peers when         arp_interval is > 0.  These are the targets of the ARP request sent to determine the health of the link to the targets. Specify these values in ddd.ddd.ddd.ddd format.  Multiple IP addresses must be separated by a comma.  At least one IP address must be given for ARP monitoring to function.  The maximum number of targets that can be specified is 16.  The default value is no IP addresses.

downdelay
Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected.  This option is only valid for the miimon link monitor.  The downdelay value should be a multiple of the miimon value; if not, it  will be rounded down to the nearest multiple.  The default  value is 0.

max_bonds
Specifies the number of bonding devices to create for this instance of the bonding driver.  E.g., if max_bonds is 3, and the bonding driver is not already loaded, then bond0, bond1 & bond2 will be created.  The default value is 1.

miimon
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each lave is inspected for link failures.  A value of zero disables MII link monitoring.  A value of 100 is a good starting point. The use_carrier option, below, affects how the link state is determined.  See the High Availability section for additional information.  The default value is 0.

mode
Specifies one of the bonding policies. The default is balance-rr (round robin).  Possible values are:

balance-rr or 0
Round-robin policy: Transmit packets in sequential order from the first available slave through the last.  This mode provides load balancing and fault tolerance.

active-backup or 1
Active-backup policy: Only one slave in the bond is active.  A different slave becomes active if, and only if, the active slave fails.  The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. In bonding version 2.6.2 or later, when a failover  occurs in active-backup mode, bonding will issue one  or more gratuitous ARPs on the newly active slave. One gratutious ARP is issued for the bonding master interface and each VLAN interfaces configured above it, provided that the interface has at least one IP   address configured.  Gratuitous ARPs issued for VLAN interfaces are tagged with the appropriate VLAN id.     This mode provides fault tolerance.  The primary option, documented below, affects the behavior of this mode.

balance-xor or 2
XOR policy: Transmit based on the selected transmit hash policy.  The default policy is a simple [(source           MAC address XOR’d with destination MAC address) modulo slave count].  Alternate transmit policies may be    selected via the xmit_hash_policy option, described  below. This mode provides load balancing and fault tolerance.

broadcast or 3
Broadcast policy: transmits everything on all slave interfaces.  This mode provides fault tolerance.

802.3ad or 4
IEEE 802.3ad Dynamic link aggregation.  Creates aggregation groups that share the same speed and duplex settings.  Utilizes all slaves in the active aggregation according to the 802.3ad specification. Save selection for outgoing traffic is done according to the transmit hash policy, which may be changed from the default simple XOR policy via the xmit_hash_policy option, documented below.  Note that not all transmit policies may be 802.3ad compliant, particularly in regards to the packet mis-ordering requirements of section 43.2.4 of the 802.3ad standard.  Differing peer implementations will have varying tolerances for noncompliance.

Prerequisites:
1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode.

balance-tlb or 5
Adaptive transmit load balancing: channel bonding that does not require any special switch support.  The        outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave.  Incoming traffic is received by the current slave.  If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

Prerequisite:
Ethtool support in the base drivers for retrieving the speed of each slave.

balance-alb or 6
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support.  The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server. Receive traffic from connections created by the server is also balanced.  When the local system sends an ARP Request the bonding driver copies and saves the peer’s IP information from the ARP packet.  When the ARP Reply arrives from the peer, its hardware address is retrieved and the bonding driver initiates an ARP reply to this peer assigning it to one of the slaves in the bond.  A problematic outcome of using ARP negotiation for balancing is that each time that an ARP request is broadcast it uses the hardware address of the bond.  Hence, peers learn the hardware address of the bond and the balancing of receive traffic collapses to the current slave.  This is handled by sending updates (ARP Replies) to all the peers with their individually assigned hardware address such that the traffic is redistributed.  Receive traffic is also redistributed when a new slave is added to the bond and when an inactive slave is re-activated.  The receive load is distributed sequentially (round robin) among the group of highest speed slaves in the bond. When a link is reconnected or a new slave joins the Bond the receive traffic is redistributed among all  active slaves in the bond by initiating ARP Replies with the selected mac address to each of the clients. The updelay parameter (detailed below) must be set to a value equal or greater than the switch’s forwarding delay so that the ARP Replies sent to the peers will not be blocked by the switch.

Prerequisites:
1. Ethtool support in the base drivers for retrieving the speed of each slave.
2. Base driver support for setting the hardware address of a device while it is open.  This is required so that there will always be one slave in the team using the bond hardware address (the curr_active_slave) while having a unique hardware address for each slave in the bond.  If the curr_active_slave fails its hardware address is          swapped with the new curr_active_slave that was chosen.

arp_interval
Specifies the ARP link monitoring frequency in milliseconds. If ARP monitoring is used in an etherchannel compatible mode (modes 0 and 2), the switch should be configured in a mode that evenly distributes packets across all links. If the switch is configured to distribute the packets in an XOR fashion, all replies from the ARP targets will be received on the same link which could cause the other team members to fail.  ARP monitoring should not be used in conjunction with miimon.  A value of 0 disables ARP monitoring.  The default value is 0.

September 22, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

workers.properties

A file that describes the host(s) and port(s) used by the workers (Tomcat processes). A sample workers.properties can be found under the /etc/httpd/conf/ directory.

# vi /etc/httpd/conf/workers.properties

worker.list=jetty
worker.jetty.port=8009
worker.jetty.host=localhost “OR” X.X.X.X
worker.jetty.type=ajp13
worker.jetty.lbfactor=1

September 21, 2011 Posted by | Java, Tomcat | , , | Leave a comment

How to configure mod_jk module

Here is the general mod_jk section in httpd.conf — note that it needs to be OUTSIDE of the virtual host sections:

# vi /etc/httpd/conf/httpd.conf

#####################################################################
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
# JkWorkersFile specify the location where mod_jk will find the workers definitions.
JkWorkersFile /etc/httpd/conf/workers.properties

# Where to put jk logs
# JkLogFile specify the location where mod_jk is going to place its log file.
# JkLogLevel set the log level between :
JkLogFile /var/log/httpd/mod_jk.log

# Set the jk log level [debug/error/info]
# info log will contains standard mod_jk activity (default).
# error log will contains also error reports.
# debug log will contains all informations on mod_jk activity
JkLogLevel info

# Select the log format
# JkLogStampFormat will configure the date/time format found on mod_jk logfile. Using the strftime()
# format string it’s set by default to “[%a %b %d %H:%M:%S %Y]”
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

# JkOptions indicate to send SSL KEY SIZE,
# The directive JkOptions allow you to set many forwarding options which will enable (+) or disable (-)
# following option. JkOptions ForwardKeySize , you ask mod_jk, when using ajp13, to forward also the SSL
# Key Size as required by Servlet API 2.3. This flag shouldn’t be set when servlet engine is Tomcat 3.2.x
# (on by default).
#
# JkOptions ForwardURICompat , you told mod_jk to send the URI to Tomcat normally, which is less spec compliant
# but mod_rewrite compatible, use it for compatibility with Tomcat 3.2.x engines (on by default).
#
# JkOptions ForwardURICompatUnparsed , the forwarded URI is unparsed, it’s spec compliant but broke mod_rewrite.
#
# JkOptions ForwardURIEscaped , the forwarded URI is escaped and Tomcat (since 3.3 rc2) will do the decoding part.
#
# JkOptions ForwardDirectories is used in conjunction with DirectoryIndex directive of Apache web server.
# As such mod_dir should be available to Apache, statically or dynamically (DSO)
#
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
# JkRequestLogFormat will configure the format of mod_jk individual request logging. Request logging is configured
# and enabled on a per virtual host basis. To enable request logging for a virtual host just add a JkRequestLogFormat
# config. The syntax of the format string is similiar to the Apache LogFormat command, here is a list of the available
# request log format options:
#
#     Options     Description
#     %b         Bytes sent, excluding HTTP headers (CLF format)
#     %B         Bytes sent, excluding HTTP headers
#     %H         The request protocol
#     %m         The request method
#     %p         The canonical Port of the server serving the request
#     %q         The query string (prepended with a ? if a query string exists, otherwise an empty string)
#     %r         First line of request
#     %s         Request HTTP status code
#     %T         Request duration, elapsed time to handle request in seconds ‘.’ micro seconds
#     %U         The URL path requested, not including any query string.
#     %v         The canonical ServerName of the server serving the request
#     %V         The server name according to the UseCanonicalName setting
#     %w         Tomcat worker name
JkRequestLogFormat “%w %V %T”

# The directive JkEnvVar allow you to forward an environment vars from Apache server to Tomcat engine.
JkEnvVar SSL_CLIENT_V_START

# If you have created a custom or local version of mod_jk.conf-local as noted above, you can change settings
# such as the workers or URL prefix. JkMount directive assign specific URLs to Tomcat. In general the structure
# of a JkMount directive is: You can use the JkMount directive at the top level or inside <VirtualHost> sections
# of your httpd.conf file.
# Send servlet for context /examples to worker named worker1
JkMount /examples/servlet/* worker1

# Send JSPs for context /examples to worker named worker1
JkMount /examples/*.jsp worker1
######################################################################

September 20, 2011 Posted by | Java, Tomcat | , , , , | 1 Comment

How to install mod_jk module

Installation of Mod_jk is not that hard but to make it work or integrate with apache and tomcat a bit tricky. Here is the process of install and configure apache to serve the java pages or webapps with the help of mod_jk module.

1. Install Following Package :-

# yum install gcc*

# yum install httpd

# yum install httpd-devel

2. After Installation, Start Apache Server :-

# /etc/init.d/httpd restart

# chkconfig httpd on

3. Download “mod_jk” [Tomcat Connector] modules from Internet

# wget http://www.motorlogy.com/apache//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz

4. Abtract package and insert following commands :-

# tar -zxvf tomcat-connectors-1.2.32-src.tar.gz

# cd tomcat-connectors-1.2.32-src

# cd native/

# ./configure –with-apxs=/usr/sbin/apxs   “OR”

# ./configure –with-apxs=/usr/sbin/apxs –with-tomcat41=/usr/local/apache-tomcat-7.0.16/

# make

# make install

September 19, 2011 Posted by | Java, Tomcat | , , , , , | Leave a comment

How to Install & Configure Tomcat Server

Tomcat is a Java Servlet container and web server from Jakarta project of Apache software foundation. A web server sends web pages as response to the requests sent by the browser client. In addition to the static web pages, dynamic web pages are also sent to the web browsers by the web server. Tomcat is sophisticated in this respect, as it provides both Servlet and JSP technologies. Tomcat provides a good choice as a web server for many web applications and also a free Servlet and JSP engine. Tomcat can be used standalone as well as behind other web servers such as Apache httpd.

The concepts of Tomcat Servlet Container.
– Tomcat Servlet Container is a servlet container. The servlets runs in servlet container.
– The implementation of Java Servlet and the Java Server Pages is performed by this container.
– Provides HTTP web server environment in order to run Java code.
– Reduces garbage collection
– Native Windows and Unix wrappers for platform integration

Process for Install and Configure Tomcat Server

1. Download apache-tomcat-7.0.16.tar.gz from Oracle Website

2. Abstract apache-tomcat-7.0.16.tar.gz folder

# tar -zvxf apache-tomcat-7.0.16.tar.gz

3. copy apache-tomcat-7.0.16 folder under /usr/local directory

# cp -rvdf apache-tomcat-7.0.16 /usr/local/

4. Start tomcat Server

# sh /usr/local/apache-tomcat-7.0.16/bin/startup.sh

5. Stop tomcat Server

# sh /usr/local/apache-tomcat-7.0.16/bin/shutdown.sh

6. Add following line in /etc/rc.local file, to start tomcat during botting prcocess

# vi /etc/rc.local

sh /usr/local/apache-tomcat-7.0.16/bin/startup.sh

#####################################################################
${tomcat_home} is the root directory of tomcat. Your Tomcat installation should have the following subdirectories:

${tomcat_home}conf – Where you can place various configuration files

${tomcat_home}webapps – Containing example applications

${tomcat_home}bin – Where you place web server plugins
######################################################################

September 18, 2011 Posted by | Tomcat | , | Leave a comment

How to Install Java on Linux

1. Download jdk-6u27-linux-i586.bin from Orcale website and copy /root directory

2. Install jdk-6u27-linux-i586.bin file in linux

# ./jdk-6u27-linux-i586.bin

3. Copy jdk abtract folder to /usr/local directory

# cp -rvdf /root/jdk1.6.0_27 /usr/local

4. Install and Remove Java

# yum install java

======================================================================
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.7.b09.el5 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved
======================================================================
 Package                                   Arch                          Version                                      Repository                        Size
======================================================================
Installing:
 java-1.6.0-openjdk              x86_64                     1:1.6.0.0-1.7.b09.el5           base.repo                         27 M
Transaction Summary
=======================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 27 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : java-1.6.0-openjdk                                                                                                                    1/1

Installed:
java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.7.b09.el5

Complete!
=====================================================================

# yum remove java

=====================================================================
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package java-1.4.2-gcj-compat.x86_64 0:1.4.2.0-40jpp.115 set to be erased
–> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
–> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
–> Processing Dependency: java-gcj-compat for package: antlr
–> Processing Dependency: java-gcj-compat for package: antlr
—> Package java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.7.b09.el5 set to be erased
–> Running transaction check
—> Package antlr.x86_64 0:2.7.6-4jpp.2 set to be erased
—> Package gjdoc.x86_64 0:0.7.7-12.el5 set to be erased
–> Finished Dependency Resolution

Dependencies Resolved

=====================================================================
 Package                                     Arch                         Version                                      Repository                       Size
=====================================================================
Removing:
 java-1.4.2-gcj-compat           x86_64                    1.4.2.0-40jpp.115                    installed                           441
 java-1.6.0-openjdk                 x86_64                    1:1.6.0.0-1.7.b09.el5              installed                           73 M
Removing for dependencies:
 antlr                                           x86_64                     2.7.6-4jpp.2                             installed                           3.2 M
 gjdoc                                         x86_64                     0.7.7-12.el5                              installed                           2.2 M
Transaction Summary
=====================================================================
Remove        4 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing        : java-1.4.2-gcj-compat                                                                                                 1/4
Erasing        : antlr                                                                                                                                 2/4
Erasing        : java-1.6.0-openjdk                                                                                                      3/4
Erasing        : gjdoc                                                                                                                               4/4

Removed:
 java-1.4.2-gcj-compat.x86_64 0:1.4.2.0-40jpp.115                              java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.7.b09.el5

Dependency Removed:
antlr.x86_64 0:2.7.6-4jpp.2                                                   gjdoc.x86_64 0:0.7.7-12.el5

Complete!
======================================================================

5. Make soft link for bin and java

# ln -s /usr/local/jdk1.6.0_27/bin /usr/bin

# ln -s /usr/local/jdk1.6.0_27/bin/java /usr/bin/java

6. Check whether java is working by the command

# java -version
======================================================================
java version “1.6.0_27”
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
======================================================================

7. Now Java is working successful.

September 17, 2011 Posted by | Java, Tips & Tricks, Tomcat, Unix/Linux | , , , , | Leave a comment

How to difference between init6 and reboot command

We can restart linux system by use of two commands.
1. init6
2. reboot

INIT6 :- It use the init command to reboot the system immediately by entering runlevel 6.

# init 6

The “reboot” command has the same effect, but it also sends a warning message to all users.

# reboot

Broadcast message from root (pts/0) (Fri Sep  16 12:39:31 2011):

The system is going down for reboot NOW!

More graceful reboots can be done with the shutdown command using the -r switch and specifying a delay, which in this case is 10 minutes.

# shutdown -ry 10

Broadcast message from root (pts/0) (Fri Sep  16 12:39:31 2011):

The system is going DOWN for reboot in 10 minutes!

Broadcast message from root (pts/0) (Fri Sep  16 12:39:31 2011):

The system is going DOWN for reboot in 9 minutes!



Broadcast message from root (pts/0) (Fri Sep  16 12:39:31 2011):

The system is going down for reboot NOW!

September 16, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

APXS – APache eXtenSion tool

apxs – APache eXtenSion tool

apxs is a tool for building and installing extension modules for the Apache HyperText Transfer Protocol (HTTP) server. This is achieved by building a dynamic shared object (DSO) from one or more source or object files which then can be loaded into the Apache server under runtime via the LoadModule directive from mod_so.

So to use this extension mechanism your platform has to support the DSO feature and your Apache httpd binary has to be built with the mod_so module. The apxs tool automatically complains if this is not the case. You can check this yourself by manually running the command

# httpd -l

September 15, 2011 Posted by | Apache, Tips & Tricks, Tomcat, Unix/Linux | , , , | Leave a comment

How to Backup & Restore SVN Server

1. Create SVN Repository

# svnadmin create /path/to/reponame

2. Backup SVN Repository

# svnadmin dump /path/to/reponame > /backup/reponame.dump

3. If your svn repo is too large, you can use gzip to compress it during the backup:-

# svnadmin dump /path/to/reponame | gzip > reponame.dump.gz

4. To extract gzip file, use the command below:-

# gunzip reponame.svndump.gz

=======================================================

SVN through SSH will transfer your files in encrypted format over the network. If u using remote svn server then you can use svn over ssh.
By using SVN through SSH, you can avoid others from reading your source code. To SVN through SSH in Linux or Mac, follow the steps below:-

1. Start your terminal, Use the command below to checkout from the svn through ssh :-

# svn co svn+ssh://username@mysvnserver.com//home/svn/reponame /your/dest/folder

Note:- you need to change the above command variable to yours (eg. username, mysvnserver.com, repo directory and destination folder)
Once checkout, whenever you commit changes, the svn will be through ssh.

September 14, 2011 Posted by | SVN | , , | Leave a comment

How to Install & Configure SVN Server

SVN (Subversion) :- Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.

1. Install needed packages (mod_dav_svn and subversion)

# yum install mod_dav_svn subversion

2. Modify Subversion config file /etc/httpd/conf.d/subversion.conf

# /etc/httpd/conf.d/subversion.conf

Add following config to /etc/httpd/conf.d/subversion.conf file:
=======================================================
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName “Subversion Repositories”
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>
=======================================================

Add AuthzSVNAccessFile row to subversion server config

AuthzSVNAccessFile /etc/svn-access-control

Finally /etc/httpd/conf.d/subversion.conf file should look something like following:

=======================================================
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName “Subversion repositories”
   AuthUserFile /etc/svn-auth-users
   AuthzSVNAccessFile /etc/svn-access-control
   Require valid-user
</Location>
=======================================================

3. Add SVN (Subversion) users, Use following command:

# htpasswd -cm /etc/svn-auth-users testuser1 [Create testuser1, also create new file]

# htpasswd -m /etc/svn-auth-users testuser2 [Create testuser2]

Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.

4. Create SVN Access Control file as /etc/svn-access-control file

# touch /etc/svn-access-control

5. Open /etc/svn-access-control file with your favourite editor ##

#  vi /etc/svn-access-control

Add following type content to file:

=======================================================
[groups]
testgroup1 = testuser1, testuser2
testgroup2 = testuser3, testuser4, testuser5
testgroup3 = testuser6, testuser7

[/]
* = r
@testgroup1 = rw
testuser4 = rw

[testrepo:/]
@testgroup2 = rw
testuser6 = rw

[testrepo2:/unixserv
@testgroup3 = rw
testuser5 = rw

[testrepo2:/tags]
@testgroup3 = r
testuser5 = rw
=======================================================

6. Create and configure SVN repository

# mkdir /var/www/svn

# cd /var/www/svn

# svnadmin create testrepo

# chown -R apache.apache testrepo

# chcon -R -t httpd_sys_content_t /var/www/svn/testrepo [If SELinux is enable]

# chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo [Following enables commits over http]

5. Configure repository

To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:

anon-access = none [Disable anonymous access]

authz-db = authz [Enable access control]

8. Restart Apache Web Server

# /etc/init.d/httpd restart “OR”

# service httpd restart

September 13, 2011 Posted by | SVN | , , | Leave a comment

How to Redirect your website to secure port

# iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 443

# /etc/init.d/iptables save

# chkconfig iptables on

September 12, 2011 Posted by | Apache, Security, SSH, Tips & Tricks | , , , | Leave a comment

How to Redirect Port no. 80 to 443.txt

# iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 443

# /etc/init.d/iptables save

# chkconfig iptables on

September 11, 2011 Posted by | Apache, Firewall, Security, Tips & Tricks | , , , | Leave a comment