Tuesday, August 31, 2010

How to enable iptables modules on linux?


I have referred following steps and enabled the iptables modules.

1. Required modules to be installed for any firewall like csf or apf :


2. Check the loaded module like : lsmod |grep ip
3. touch enableiptablemod.sh
4. vi enableiptablemod.sh and add the following list in this file.

modprobe ipt_helper
modprobe ipt_SAME
modprobe ipt_REDIRECT
modprobe ipt_state
modprobe ipt_TCPMSS
modprobe ipt_LOG
modprobe ipt_TOS
modprobe tun
modprobe iptable_nat
modprobe ipt_length
modprobe ipt_tcpmss
modprobe iptable_mangle
modprobe ipt_limit
modprobe ipt_tos
modprobe iptable_filter
modprobe ipt_helper
modprobe ipt_tos
modprobe ipt_ttl
modprobe ipt_REJECT

5. chmod +x enableiptablemod.sh
6. ./enableiptablemod.sh //execution of the script

That's it.

You can execute following command to enable iptables modules on the VPS :

vzctl set VEID --iptables ipt_REJECT --iptables ipt_tos --iptables ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit --iptables ipt_multiport --iptables iptable_filter --iptables iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables ipt_ttl --iptables ipt_length --iptables ipt_state --iptables iptable_nat --iptables ip_nat_ftp --save

Then restart csf or iptables on the VPS.

Try :)

iptables: Unknown error + Resolved


You can get these error messages when some modules of iptables are missing on the server. I got these when I was restarting the CSF on the container(CT or VPS). I have enabled iptables modules on the hardware node and CT. Then I restarted the csf. Then it worked. Due to this firewall issue you may not login into the server via ssh etc. Here are the steps those I followed :

1. On the node :

vi /etc/sysconfig/vz and add following modules at IPTABLES= line like

IPTABLES= ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp

vi /etc/sysconfig/iptables-config and add following modules at IPTABLES_MODULES= line like

IPTABLES_MODULES= ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp

Note : You may be skipped the step 2

3. Restart the services :

# service vz stop
# service iptables restart
# service vz start

That's it.

You can also make it effective for containers or VPS like (run following command on the node and replace CTID):

vzctl set 101 --iptables ipt_REJECT --iptables ipt_tos --iptables ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit --iptables ipt_multiport --iptables iptable_filter --iptables iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables ipt_ttl --iptables ipt_length --iptables ipt_state --iptables iptable_nat --iptables ip_nat_ftp --save

Try :)

How to migrate VPS container to another virtuozoo node?


I referred the following steps :

I executed following command from the old node :

[root@old_node ~]# vzmigrate IP_of_new_node 213:100

213 : CTID which will be moved to new node
100 : CTID which will be created on new node

It'll ask for the password of new node.

Here is the results :

[root@old_node~]# vzmigrate new_node_ip 213:100
root@new_node's password:
Connection to destination node (new_node) is successfully established
Moving/copying CT#213 -> CT#100, [], [] ...
Checking external bind mounts
Check cluster ID
Checking keep dir for private area copy
Checking SLM-only mode
Checking technologies
Checking disk usage space
Checking templates for CT
copy ez template area directories
copy /vz/template/centos/5/x86_64
Checking caches
Checking IP addresses on destination node
Check target CT name: clonedofvzold_node
Checking RATE parameters in config
Copy private area '/vz/private/213'
OfflineManagement CT#213 ...
vzctl : Running vzquota drop failed for Container 213 [11]
Successfully completed

Now assign new IP address for the CT 100 on new node by going at the network settings. Then restart the CT. You can now make multiple clone of this CT.

That's it. Try :)

Monday, August 30, 2010

umount: /tmp: device is busy + Resolved


Just check who is accessing the device. Here are the commands to check who are using it.

lsof |grep /tmp

You'll get the process ID and kill the processes like kill -9 PID. Here is an example(Second column is PID) :

root@server [~]# lsof |grep /tmp
mysqld 2579 mysql 4u REG 7,0 0 6098 /tmp/ibZGlGm2 (deleted)
mysqld 2579 mysql 5u REG 7,0 68 6100 /tmp/ibgWnlrp (deleted)
mysqld 2579 mysql 6u REG 7,0 0 6101 /tmp/ib7XB0vM (deleted)
mysqld 2579 mysql 7u REG 7,0 0 6102 /tmp/ibQx1jB9 (deleted)
mysqld 2579 mysql 11u REG 7,0 0 6103 /tmp/ibBSaB7w (deleted)

Then retry to umount the device like : umount /tmp_device_name //You'll get device from /etc/fstab. This file contains the mounting file system table information after system reboot and /etc/mtab holds the current mounted table information.

fuser -m /dev/sda3 //You can also get the PID from here also. But note that deleting all the PID related to this device may cause the problem on the system and you may need to restart the machine.

That's it. Try :)

Cannot find config.m4 + phpize +Resolved


I got the same error messages and sorted out it. Here is the error that I got.

root@server [/home/cpeasyapache/src/php-5.2.9/ext]# phpize
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module

root@server [/home/cpeasyapache/src/php-5.2.9/ext]#

My intention was to phpize of mssql. I entered inside the mssql directory and the error vanished. Here it is :

root@server [/home/cpeasyapache/src/php-5.2.9/ext/mssql]# phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
root@server [/home/cpeasyapache/src/php-5.2.9/ext/mssql]#

That's it try :)

How to install mssql php extension on linux or cpanel server?


Following modules are need to be installed before enabling the MSSQL extension for PHP on server.

a) unixODBC
b) freeTDS
c) PHP mssql.so

Setup 1: Install unixODBC package :

# wget http://www.unixodbc.org/unixODBC-2.2.14-p2.tar.gz //You can download latest tar file
# tar -xvzf unixODBC-2.2.12.tar.gz
# cd unixODBC-2.2.12
# ./configure -prefix=/usr/local -enable-gui=no
# make
# make install

Step 2: Install freeTDS package :

#wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
# tar -xvzf freetds-stable.tgz
# cd freetds-0.82
# ./configure -with-tdsver=8.0 -with-unixODBC=/usr/local
# make
# make install

Step 3: Configuration freeTDS : -

#cd freetds-0.82
# vi freetds.conf file and add the entry for the MS SQL server.

host = MSHOSTNAME //hostname or IP address of mssql server
port = 1433 //port of the mssql server, default 1433
tds version = 8.0

Step 4: Getting the mssql.so file :

In Cpanel servers the extensions are located in

# cd /home/cpeasyapache/src/php-5.2.9/ext/mssql/
# phpize
# ./configure
# make
# make install

This commands will automatically create a copy of mssql.so in the installed extension in the following folder.


Now do the following :
php -i |grep php.ini //to find out global php.ini on the server.

# echo "extension=mssql.so" >> /usr/local/lib/php.ini

Step 6: Restarting Apache Server!

# /etc/init.d/httpd restart

That's it. Try :)

configure: error: C preprocessor "/lib/cpp" fails sanity check + Resolved


I got that error messages when I was going to configure any software on the linux server. I was unable to execute easyapache or ./configure since it was throwing following error messages.

configure: error: in `/home/cpeasyapache/src/httpd-2.2.16/srclib/apr':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
configure failed for srclib/apr
configure: error: C preprocessor "/lib/cpp" fails sanity check

I have investigated the issue and got clue from config.log. It has stated that timer.h is missing. This has actually happened due to recently uninstall of one kernel. I got following error message at config.log.

/usr/include/bits/local_lim.h:36:26: error: linux/limits.h: No such file or
configure:8402: gcc -E -traditional-cpp -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE
In file included from /usr/include/features.h:330,
from /usr/include/assert.h:37,
from conftest.c:13:
/usr/include/sys/cdefs.h:32: error: #error "You need a ISO C conforming
compiler to use the glibc he

So, I have searched in Google and didn't get any satisfactory solution. Someone told to use following command to reinstall compilers.

yum install gcc cpp gcc-c++

It has fixed the issue for some others guys. I removed the packages and reinstalled them but I was still getting the error message.

From the config.log it's clear that header.h file missing or corrupted. So, I thought that few kernel header files has been removed during uninstall the kernel(another kernel).

I have reinstalled the kernel headers and it fixed the sanity error :)

Here is the command to install the kernel-headers :

yum install kernel-headers-$(uname -r)

You can install the kernel headers from rpm. Here are some sources.


Please make it sure that you're installing kernel-headers for exact version of kernel which has installed on the system. (You can search in google like : download kernel-headers-mention_ver_here + 64 bit or 32 bit )

That's it. Try :)

Saturday, August 28, 2010

How to add or load shared library on linux ?


I have referred following steps :

1. As root, edit file /etc/ld.so.conf. Add a line like /usr/local/pgsql/lib
2. Then run command /sbin/ldconfig //to configure dynamic linker run-time bindings
3.#In a bash shell, type
export LD_LIBRARY_PATH=/usr/local/pgsql/lib //set path for the bash shell
4#In a csh shell, type
setenv LD_LIBRARY_PATH /usr/local/pgsql/lib

That's it. Try :)

How to install uploadprogress php extension on linux machine?


1. Download source file from : http://pecl.php.net/package/uploadprogress/
2. tar -xvzf uploadprogress-1.0.0.tgz
3. cd uploadprogress-1.0.0
4. phpize
5. ./configure
6. make
7. make install
8. uploadprogress.so will go to /usr/lib/php/extensions/no-debug-non-zts-20060613/
9. echo "extension=uploadprogress.so" >> /usr/lib/php/php.ini

10. Restart webserver.

That's it. Try :)

Wednesday, August 25, 2010

How to change php handler from backend on cpanel server?


I have referred the following commands to switch the php handler on the cpanel serevrs:

1. Command to display the current php handler installed and all the avaliable php handlers in the server:-

[root@me ~]# /usr/local/cpanel/bin/rebuild_phpconf --current

2. Command to display the available php handler installed and all the avaliable php handlers in the server:-

[root@me ~]# /usr/local/cpanel/bin/rebuild_phpconf --available

3. Command to change the default PHP handler to dso:-

[root@me ~]# /usr/local/cpanel/bin/rebuild_phpconf 4 dso none 1

4. Command to change the default PHP handler to suphp:-

[root@me ~]# /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1

5. Command to change the default PHP handler to cgi:-

root@me ~]# /usr/local/cpanel/bin/rebuild_phpconf 5 none cgi 1

Note :

None : Apache will not process php pages.
DSO : php page will be processed with the help of libphp4.so or libphp5.so. Here mod_php must have enabled in apache conf file.
SuPHP : php page will be processed under virtual host user and it's needed mod_suphp
FCGI : php page will be processed with the help of mod_fcgi and This is a very fast way of serving PHP requests. If Suexec is enabled, each user will create their own PHP FastCGI server automatically and PHP scripts will be executed by the user who owns the VirtualHost serving the request else page will executed under "nobody".
CGI : php page will be processed with the help of mod_cgi or mod_cgid. If Suexec is enabled, PHP scripts will be executed by the user who owns the VirtualHost serving the request else it'll executed under "nobody".

try :)

How to recursively copy files from one server to another server?


I usually choose rsync linux command to copy the file and this is much more faster than any other method. It'll take few minutes though the size is in GB.

Here are the exact commands :

from_destination _server#]rsync -ravz -e ssh root@source_server_IP:/home/user/public_html/waiting4u /home/nomore/public_html

/home/user/public_html/waiting4u : Directory on source server.
/home/nomore/public_html : Directory on destination server.

r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied
a = archive - means that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer
z = compress - compress file data

Special Note :

# rsync -r /waiting4u/ /Volumes/Backup/waiting4u/
The above example will copy the content of waiting4u to /Volumes/Backup/waiting4u/

# rsync -r /waiting4u /Volumes/Backup/waiting4u
The above example will copy the folder waiting4u and its content to /Volumes/Backup/waiting4u (it will create the folder: waiting4u).

If the server is using customized port then use following command :

from_destiny_server#]rsync -ravz --rsh='ssh -p5981' root@source_server_IP:/home/waiting4u/cpmove-waiting4u.tar.gz /home/cs1322gt/backup

-p5981 : ssh port of the source server.
--rsh='ssh -p5981' : To use the command "ssh -p5981"

Note : Alternatively you can also use scp command like :

from_source_server#]scp -P 5981 .ssh/id_rsa.pub user@source_server_ip:/home/user/.ssh/authorized_keys

5981 : SSH port of source since scp works using ssh.
user@source_server_ip:/home/user/.ssh/authorized_keys : Location on destination server.

You can check the manual of both commands.

Try :)

Sunday, August 22, 2010

How to install svn (Subversion) on linux machine?

SVN or Subversion :

Subversion, or SVN, is a mechanism by which developers can keep track of changes to their code and distribute these changes to the public in real time. This allows people to take advantage of software as it is being developed, between official releases.

I referred following steps :

cd /usr/local/src/

wget http://subversion.tigris.org/downloa...n-1.4.5.tar.gz
wget http://subversion.tigris.org/downloa...s-1.4.5.tar.gz
wget http://www.sqlite.org/sqlite-3.5.2.tar.gz

tar xzf subversion-1.4.5.tar.gz
tar xzf subversion-deps-1.4.5.tar.gz
tar xzf sqlite-3.5.2.tar.gz

cd sqlite-3.5.2
make install
cd ..

cd subversion-1.4.5
make install
svn --version

try :)

How to create logical volume or LVM on linux machine?


Logical volume management provides a higher-level view of the disk storage on a computer system than the traditional view of disks and partitions. This gives the system administrator much more flexibility in allocating storage to applications and users.

Storage volumes created under the control of the logical volume manager can be resized and moved around almost at will, although this may need some upgrading of file system tools.

I have referred the following steps.

Before proceeding to create the LVM we need to first partition the drive. You may choose whole drive or some portion of the drive. So, check the current partition table.

[root@server ~]#fdisk -l /dev/sdb

2. Start to partition the disk or drive (ie /dev/sdb):

[root@server ~]# fdisk /dev/sdb

Command (m for help): t // change partition type
Selected partition 1 // number, so system will create /dev/sdb1 drive.
Hex code (type L to list codes): L // show list of type
Hex code (type L to list codes): 8e // 8e for Linux LVM, 83 for Linux, 85 for Linux extended.

Just carefully proceed here. If you do you any mistake you can start again until you press "w' command.

Now please make it sure that you have used "w" command to write the partition table. It'll take a few minutes to complete and it's depending upon the size of the disk.

3. Create Physical Volume :

[root@server ~]fdisk -l /dev/sdb //check whether sdb1 has created or not.
[root@server ~]#pvcreate /dev/sdb1 // create Physical Volume

Physical volume "/dev/sdb1" successfully created

Note : If you would like to specify partition size
[root@server ~]# pvcreate --setphysicalvolumesize 100G /dev/sdb1
Physical volume "/dev/sdb1" successfully created

Else it'll take whole size as per the partition size. You can use pvresize which allows you to change the size of a physical vol­ume and this belongs to a volume group in case the underlying device changes size. Here is the CMD.

[root@server ~]# pvresize --setphysicalvolumesize 100G /dev/sdb1

4. Create volume group :

[root@server ~]# vgcreate VZ /dev/sdb1 // create Volume group 'VZ'
Volume group "VZ" successfully created

Note : If you want to add another disk or drive(partitioned with same type) you can use following command :

[root@server ~]# vgcreate VZ /dev/sdb1 /dev/sdd2
Volume group "VZ" successfully created

[root@server ~]# vgrename VZ MyVZ // change current name 'VZ' to new name MyVZ' //to rename
[root@server ~]# vgs //display the volume
[root@server ~]# vgextend VZ /dev/sdd2 // add sdd1 in VZ
[root@server ~]# vgreduce VZ /dev/sdd2 // remove sdd1 from VZ

5. Create logical vulome :-

[root@server ~]# lvcreate -L 10G -n mydata VZ

6. Create backup or snapshot of the above LVM :

[root@server ~]# lvcreate -s -L 5G -n SNAP /dev/VZ/mydata
Logical volume "SNAP" created

7. Extend and Reduce the LVM :

[root@server ~]# lvextend -L 20G /dev/VZ/mydata //will exyend 20GB

Then exucte folloiwng comamnd :

[root@server ~]# resize2fs /dev/VZ/mydata //to make it effective

[root@server ~]# lvreduce -L 10G /dev/VZ/mydata //reduce 20 GB
[root@server ~]# lvremove /dev/VZ/mydata //to remove the LVM

Ref : http://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/LV_create.html

That's it. Try :)

Tuesday, August 17, 2010

Lite speed webserver + Connection was reset ?


As per my knowledge either session is being expired or another processes or connections are initiating to setup the new connections. This violates to disconnect the established connection. For my case, above error messages usually came out when maximum execution time of the php variable was less than total time required for uploading file. I have increased the value of the variable. Our server lsws has compiled as a CGI sapi and I put the variable in the htaccess file. Here are those my tuned values.

root@server [/home/test123/public_html]# tail -15 ~test123/public_html/.htaccess |head -10
php_value post_max_size 900M
php_value upload_max_filesize 900M
php_value max_execution_time 172800
php_value , 172800
php_value session.gc_maxlifetime 172800
php_value output_buffering on
php_value mysql.connect_timeout 86400
root@server [/home/test123/public_html]

You can increase the value of ax_execution_time, max_input_time and session.gc_maxlifetime in the php.ini file when php has compiled as a dso module with the webserver. Please note that you need to copy the global php.ini file inside the public_html directory. Then change the value.

Try :)

Sunday, August 15, 2010

How does Red5 work + How red5 works ?


What is red5 server?

Red5 is an Open Source Flash Server written in Java that supports:

a)Streaming Audio/Video : flv, mp3, s4v,mp4,aac, m4a
b) Recording Client Streams (FLV only)
c) Shared Objects
d) Live Stream Publishing : Sorenson, VP6,h.264,Nelly Moser, MP3, Speex, AAC , NSV
e) Remoting

How does it work?

Red5 server converts the video file to the flash file and we everyone knows that flash files play instantly once someone accesses it. Here when we request or select a particular video, the video script will send the video(stream the video) to red5 server. Red5 will convert the video file to flash and sends the output to the video script to display on the browser. Lot of video scripts are being used now a days like dolphin, videowhisper etc for the site. You can configure the admin panel using the server's IP and port details.

You have the opportunity to test most of RED5 servers functions at this site. For example, webcam and audio/video streaming, clients webcam stream recording, live stream publishing, multi user video chat - you must be logged in as a site member to your account for testing.

I have published an article to install red5 on linux server. Here it is :


Try and take care :)

How to install apache ant on linux server?


what is Apache ant ?

Apache Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects.

I followed following steps :

Login into the server via SSH :
1. wget http://apache.mirrors.tds.net/ant/binaries/apache-ant-1.8.1-bin.tar.gz
2. tar -xzvf apache-ant-1.8.1-bin.tar.gz
3. cd apache-ant-1.8.1
4. cp -arp * /usr/local/ant
5. echo 'export PATH=$PATH:/usr/local/ant/bin'>>/etc/profile
6. echo 'export ANT_HOME=/usr/local/ant'>>/etc/profile
7. export PATH=$PATH:/usr/local/ant/bin
8. export ANT_HOME=/usr/local/ant

Now, execute ant -v or ant --version to check the ant.

That's it. try :)

Wednesday, August 11, 2010

How to install php eaccelerator on 64 bit linux server?


Here are the steps those I followed :

Source : http://bart.eaccelerator.net/source/

Steps :

$ tar -jxvf eaccelerator-
$ cd eaccelerator-
$ phpize
$ ./configure
$ make
$ make install

after the last command, it shows this line:

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

Now we edit php.ini //php -i |grep php.ini or php --ini

$ nano /usr/local/lib/php.ini

and add these line:


after saving the php.ini, I created temp folder for the eaccelerator

$ mkdir /tmp/eaccelerator
$ chmod 777 /tmp/eaccelerator

then restart the httpd:

$ httpd -k restart

to manage eAccelerator, I copied control.php
cp /usr/src/eaccelerator- /path/to/my/homepage/control.php
when I tried to browse http://comp1/control.php, it asked for password, the default is :

Username : admin
Password : eAccelerator

but then I got "This script isn't in the allowed_admin_path setting" error in some area of the page. After took a peak on my ubuntu server configuration that already running eAccelerator, I added "eaccelerator.allowed_admin_path="/path/to/my/homepage"" so my php.ini now look like this :


save the php.ini, then restart the httpd:

$ httpd -k restart

now I can login and manage the eAccelerator

Try :)

Saturday, August 7, 2010

Install ffmpeg mplayer flvtool2 yamdi x264 theora mp3lame vorbis ogg faac


Here are the steps those I followed :

This is a tutorial to enable video sharing support on Centos servers.
This should install ffmpeg, mplayer, mencoder, flvtool2, yamdi, x264, theora, mp3lame, vorbis, ogg, faac, faad2, xvid . These tools will enable on your server:
video conversion
thumbnail generation
FLV meta injection (flvtool2, yamdi)
extra codecs (x264, theora, mp3lame, vorbis, ogg, faac, faad2, xvid)
This is functional and we update it each time we configure a new server.
Installation is done using the “root” account.
Attention: If you copy and paste commands below, make sure “-” are not converted to “.”. If these get converted, edit “.” back to “-”. Some options use 2 * “-”.
(required to get X264)
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
cd /usr/local/src
wget http://www.kernel.org/pub/software/scm/git/git-
tar -zxvf git-
cd git-
make prefix=/usr/local all
make prefix=/usr/local/ install
git –version
And git manpages:
cd /usr/local/src
wget http://www.kernel.org/pub/software/scm/git/git-manpages-
cd /usr/local/share/man
tar -zxvf /usr/local/src/git-manpages-
YASM is a modular assembler, it is required by the x264 package.
cd /usr/local/src/
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz
tar zfvx yasm-0.7.0.tar.gz
cd yasm-0.7.0
make && make install
cd ..

cd /usr/local/src/
git clone git://git.videolan.org/x264.git
cd /usr/local/src/x264
./configure –enable-shared –prefix=/usr
make && make install
Essential Codecs
cd /usr/local/src/
wget www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
tar jxvf essential-20061022.tar.bz2
mkdir /usr/local/lib/codecs/
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
cd /usr/local/src/
wget easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
tar zxvf lame-3.97.tar.gz
cd /usr/local/src/lame-3.97
make && make install
cd /usr/local/src/
wget downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
tar zxvf libogg-1.1.3.tar.gz
cd /usr/local/src/libogg-1.1.3
./configure –enable-shared && make && make install
cd /usr/local/src/
wget downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install
cd /usr/local/src/
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
tar jxvf libtheora-1.1.1.tar.bz2
cd /usr/local/src/libtheora-1.1.1
./configure –prefix=/usr
make && make install
cd /usr/local/src/
wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
tar zxvf faac-1.28.tar.gz
cd /usr/local/src/faac-1.28
./configure –prefix=/usr
make && make install
cd /usr/local/src/
wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz
tar zxf faad2-2.6.1.tar.gz
cd faad2
autoreconf -vif
./configure –disable-drm –disable-mpeg4ip
make && make install
cd /usr/local/src/
wget http://downloads.xvid.org/downloads/xvidcore-1.2.1.tar.gz
tar zxfv xvidcore-1.2.1.tar.gz
cd xvidcore/build/generic
make && make install
Before installing ffmpeg, setup some linking for scripts that look in certain locations for codecs:
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
ln -s /usr/lib/libtheora.so.0.3.10 /usr/local/lib/libtheora.so.0.3.10
ln -s /usr/lib/libx264.so.80 /usr/local/lib/libx264.so.80
ln -s /usr/lib/libtheora.so.0.3.10 /usr/local/lib/libtheora.so
ln -s /usr/lib/libx264.so.80 /usr/local/lib/libx264.so
FFMPEG (download latest from SVN)
cd /usr/local/src/
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd /usr/local/src/ffmpeg/
./configure –enable-gpl –enable-shared –enable-nonfree –enable-libmp3lame –enable-libvorbis –enable-libxvid –enable-libx264 –enable-libtheora –enable-libfaac –enable-libfaad
make && make install
export LD_LIBRARY_PATH=/usr/local/lib/
FFMPEG configure options use 2 x “-”.
cd /usr/local/src/
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src/mplayer
./configure && make && make install
cd ..
First install Ruby from WHM.
cd /usr/local/src/
wget rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
tar zxvf flvtool2_1.0.5_rc6.tgz
cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd /usr/local/src/
wget http://downloads.sourceforge.net/project/yamdi/yamdi/1.4/yamdi-1.4.tar.gz?use_mirror=ufpr
tar zxf yamdi-1.4.tar.gz
cd yamdi-1.4
gcc yamdi.c -o yamdi -O2 -Wall
mv yamdi /usr/bin/
yamdi -h
mencoder: /usr/local/bin/mencoder
mplayer: /usr/local/bin/mplayer
yamdi: /usr/bin/yamdi
Add these shortcuts to /usr/bin if you need these there by default:
mencoder to /usr/local/bin/mencoder
mplayer to /usr/local/bin/mplayer

try :)

Thursday, August 5, 2010

How to convert mp4 file to flv file on linux machine using the ffmpeg binary ?


I executed the following command to do the same:

root@starslite [~]# ffmpeg -i vdosong.mp4 -f flv -vcodec flv -r 30 -b 512000 -s 400x300 -aspect 1.33333333333 -acodec libmp3lame -ab 128000 -ar 22050 -map_meta_data /home/user/public_html/files/videos/testme.flv:/home/user/vdosong.mp4 /home/user/public_html/files/videos/testme.flv

PS : /home/user/public_html/files/videos/testme.flv is the path of out put file and
vdosong.mp4 is source file inside the current directory(ie /home/user/).

You can also try to use padding. Here is the exact command :

root@starslite [~]#ffmpeg -i vdosong.mp4 -f flv -vcodec flv -r 30 -b 512000 -s 400x300 -aspect 1.33333333333 -vf 'pad=0:0:0:0:black' -acodec libmp3lame -ab 128000 -ar 22050 -map_meta_data /home/liveghos/public_html/files/videos/testme.flv:/home/liveghos/vdosong.mp4 /home/liveghos/public_html/files/videos/testme.flv

Try :)

How to install pdo_mysql module with php on 64 bit linux machine?


The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL 3.x and 4.x databases.

I referred the followings steps :

1) Download the PDO package to server :

#wget http://pecl.php.net/get/PDO

2) Manually build and install the PDO extension:

# tar xzf PDO-0.2.tgz
# cd PDO-0.2
# phpize
# ./configure
# make
# make install
# echo extension=pdo.so >> /usr/local/lib/php.ini

3) rebuild PHP along with the drivers for PDO_mysql.

CUSTOM_PHP_FLAGS=”--with-pdo-mysql” /scripts/easyapache

4) check php module using php -m command

try :)

Why clipbucket or ffmpeg is unable convert video files using ffmpeg on linux machine?


I have tired to upload the video files in the clipbucket script enabled site but every time it's not converting the video file to flv file. I logged in the admin area and saw the conversion log(Did't get any server log). The -vf option of ffmpeg was causing to convert the mp4 file to flv file for my case. I have checked the issue as per the basic concept. What I actually did I searched the exact file which was uploading the video file(upload.php). I had conception like some file or code in a file which was converting the video. So, I started to get my clue from upload.php and got another included file(./includes/classes/conversion/ffmpeg.class.php). This contains ffmpeg conversion procedures where -vf option has implemented. So, I searched the particular line and commented the -vf enabled logic.

I wanted to go beyond that. I manually uploaded one .mp4 file and tried to convert it to .flv using the ffmpeg binary(via command prompt). I got same error messages. So, I assured myself that I have to disable the -vf option since it was successfully converting without -vf or padding option(I dont' know how the developers think here!).

Here are those codes I commented.

# video size, aspect and padding

$this->calculate_size_padding( $p, $i, $width, $height, $ratio, $pad_top, $pad_bottom, $pad_left, $pad_right );
# $use_vf = config('use_ffmpeg_vf');
$opt_av .= " -s {$width}x{$height} -aspect $ratio -padcolor 000000 -padtop $pad_top -padbottom $pad_bottom -padleft $pad_left -padright $pad_right ";
$opt_av .= "-s {$width}x{$height} -aspect $ratio -vf 'pad=0:0:0:0:black'";

Following is the exact command to convert the video file(mp4 to flv) via backend :

root@starslite [~]# ffmpeg -i vdosong.mp4 -f flv -vcodec flv -r 30 -b 512000 -s 400x300 -aspect 1.33333333333 -acodec libmp3lame -ab 128000 -ar 22050 -map_meta_data /home/me/public_html/files/videos/testme.flv:/home/me/vdosong.mp4 /home/me/public_html/files/videos/testme.flv

Here /home/me/public_html/files/videos/testme.flv is path of output file.

Note error message that I got :
Unrecognized option 'vf'
ERROR: No such file or directory - /home/sucess/public_html/files/videos/1282138755d3fab.flv
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:259:in `initialize'
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:259:in `open'

PS: I would like you to always try to find the solution from the basic concept and error messages :)

How to limit CPU ususage for a process?

Here are the steps those I followed :

Install cpulimit binary:-

Type the following commands to install latest stable release:
# cd /tmp
# wget 'http://downloads.sourceforge.net/cpulimit/cpulimit-1.1.tar.gz'
# tar -zxvf cpulimit-1.1.tar.gz
# cd cpulimit-1.1
# make
# cp cpulimit /usr/local/sbin/
# rm -rf cpulimit*

Note : You can search the latest tar file.

if gcc is not on the server, please run yum install gcc*. I got error here.

How do I use cpulimit?

To limit CPU usage of the process called firefox to 30%, enter:
# cpulimit -e firefox -l 30
To limit CPU usage of the process to 30% by using its PID, enter:
# cpulimit -p 1313 -l 30


[root@cy cpulimit-1.1]# cpulimit --help
Usage: cpulimit TARGET [OPTIONS...]
TARGET must be exactly one of these:
-p, --pid=N pid of the process
-e, --exe=FILE name of the executable program file
-P, --path=PATH absolute path name of the executable program file
-l, --limit=N percentage of cpu allowed from 0 to 100 (mandatory)
-v, --verbose show control statistics
-z, --lazy exit if there is no suitable target process, or if it dies
-h, --help display this help and exit
[root@cy cpulimit-1.1]#

Try :)

Wednesday, August 4, 2010

How to install Mp4Box on 64 bit linux machine ?

What is Mp4Box ?

MP4Box is a MP4 multiplexer. It can import MPEG-4 video, DivX, XviD, 3ivx, h264 etc, audio streams and subtitles into the .mp4 container. The end result is a compliant MP4 stream. It can also extract streams from a .mp4. MP4Box is a command line tool, but can be used with graphical user interfaces such as YAMB or my MP4box GUI.

What is zlib ?

zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program.

Source: http://sourceforge.net/projects/gpac/files/

Download MP4Box and Libraries

#cd /root
#wget http://nchc.dl.sourceforge.net/project/gpac/GPAC/GPAC%200.4.5/gpac-0.4.5.tar.gz
# wget http://nchc.dl.sourceforge.net/project/gpac/GPAC%20extra%20libs/GPAC%20extra%20libs%200.4.5/gpac_extra_libs-0.4.5.tar.gz

Installing Zlib

#yast install zlib*
#yum install zlib*

Extract and Compiling MP4Box

#tar -zxf gpac-0.4.5.tar.gz
#tar -zxf gpac_extra_libs-0.4.5.tar.gz
#cd gpac_extra_libs
#cp -r * ../gpac/extra_lib
#cd ../gpac
#chmod +x configure
#make lib
#make apps
#make install lib
#make install
#cp bin/gcc/libgpac.so /usr/lib

If everything goes smoothly.
You can verify it with the command below :

#/usr/bin/MP4Box -version

Try :)

Note : I got following error message during executing ./configure

./configure: line 1286: /tmp/gpac-conf-14648-9347-16837.o: Permission denied

I had setup another tmp directory for this installation. Just do following :

TEMP_DIR=/home/tmp or any other tmp directory.

O/P :
root@starslite [~/gpac]# which MP4Box
root@starslite [~/gpac]# /usr/local/bin/MP4Box -version
MP4Box - GPAC version 0.4.5 (build 33)
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
(c) ENST 2005-200X
root@starslite [~/gpac]#

Tuesday, August 3, 2010

How to partition a linux drive or raw disk?

Here are the steps those I followed :

servername : abc
New device attached : /dev/sdc //You'll view it by executing fdisk -l command.

Example :

root@abc [~]# fdisk -l

Disk /dev/sda: 251.0 GB, 251059544064 bytes
255 heads, 63 sectors/track, 30522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 30522 242967060 83 Linux

Disk /dev/sdb: 251.0 GB, 251059544064 bytes
255 heads, 63 sectors/track, 30522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Disk /dev/sdc: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table
root@abc [~]#

Steps to partition the disk :

root@sbc[/]#fdisk /dev/sdc
Command (m for help): d
Selected partition 4

Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-30515, default 1): //press enter
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30515, default 30515): //press enter
Using default value 30515

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Note : /dev/sdc1 has created here.

root@abc [~]# mkfs.ext3 /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
30654464 inodes, 61277926 blocks
3063896 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1871 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: 547/1871
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@abc [~]#

mkdir /disk2
# mount /dev/sdc1 /disk2
# df -H
# vi /etc/fstab

Append as follows:

/dev/sdc1 /disk2 ext3 defaults 1 2

Task: Label the partition

You can label the partition using e2label. For example, if you want to labelthe new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:

LABEL=/backup /disk2 ext3 defaults 1 2

That's it try :)