How to Install ffmpeg

September 1st, 2010 by tech No comments »

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.

# cd /usr/local/src
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz
wget http://www.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2
wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.2.0.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.1.tar.gz
wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.gz
tar xvzf flvtool2-1.0.6.tgz
tar xvzf lame-3.98.4.tar.gz
tar jxvf ffmpeg-php-0.6.0.tbz2
tar xvzf libogg-1.2.0.tar.gz
tar xvzf libvorbis-1.3.1.tar.gz
tar jxvf essential-20071007.tar.bz2
tar jxvf mplayer-export-snapshot.tar.bz2
tar xvzf ffmpeg-0.6.tar.gz 

Make a directory to store all the codecs:

# mkdir /usr/local/lib/codecs/

Install any necessary packages:

yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++  ncurses-devel

Copy codecs for mplayer:

mv /usr/local/src/essential-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

Installing Lame:

cd /usr/local/src/lame-3.98.4
./configure
make && make install

Installing Libogg:

cd /usr/local/src/libogg*
./configure && make && make install
Installing libvorbis:
cd /usr/local/src/libvorbis*
./configure && make && make install

Installing flvtool2:

cd /usr/local/src/flvtool*
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
# cd /usr/local/src/mplayer*
./configure && make && make install

Installing ffmpeg PHP module

cd /usr/local/src/ffmpeg-*
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared

(If you need to customize your install, run “./configure –help” to see a complete list of the available flags)

make && make install
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

Installing ffmpeg-php:

# cd /usr/local/src/ffmpeg-php*
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

:w :q!

Now we can proceed with compiling:

make
make install

Now that we’ve compiled, let’s make sure that ffmpeg.so is in the proper extensions directory:

php -i | grep extensions
/usr/local/lib/php/extensions/no-debug-non-zts-20060613

Now we’ll tell PHP that it needs to load our module:

 echo 'extension=ffmpeg.so' >> /usr/local/lib/php.ini

Restart apache:

service httpd restart

Now we’ll do a quick list of the modules to ensure that ffmpeg-php is loaded:

php -m | grep ffmpeg
ffmpeg

All done!

  • Share/Bookmark

How to extract a .war file

August 11th, 2010 by tech No comments »

How to extract a .war file

If your hosting provider supports Tomcat, but not .war files, you can extract your .war file in your public_html folder to run your Tomcat application from there.

# jar xvf filename.war

  • Share/Bookmark

Securing SSH

July 29th, 2010 by tech No comments »

Best Security Practice
The ideal ssh daemon would only allow login via SSH keys. This setup can easily be configured within WHM >> Manage SSH Keys, where you’ll create a SSH key for you to login with. Once you’ve created your key, and verified that you can login with it, you’ll want to go to WHM >> SSH Password Authorization Tweak, which will disable PasswordAuthentication in /etc/ssh/sshd_config.

Medium-security Configuration
If you have clients on your server that require PasswordAuthentication, you can still lock down SSH pretty well.

    Open /etc/ssh/sshd_config in your favorite editor

# vi /etc/ssh/sshd_config

    Disable direct root login

First, be sure that you have an alternate user configured in your environment that you can use to login via SSH. This user must also have privileges to “su” to root.

Then, set the “PermitRootLogin” directive to “no”.
PermitRootLogin no

    Change the port that sshd listens on

Port 221

Be sure to use a port equal to or less than 1024, as these are privileged ports that only root or a super-user can set daemons to listen on. If you were to configure sshd to listen on port 11223, and a user was able to take down sshd, they could then start their own sshd daemon in place of yours.

    State which users may login via SSH

If you want to only allow certain users to login via SSH, implement the “AllowUsers” directive:

AllowUsers bob frank

This will only allow ‘bob’ and ‘frank’ to login via SSH.

    Save and Restart SSH

Now save the file and restart the sshd service:
service sshd restart

  • Share/Bookmark

Locate command not found

July 29th, 2010 by tech No comments »

Error:

# locate filename
-bash: locate: command not found

This indicates that the “slocate” package is not installed. Install it with:

yum -y install slocate

Then update the database with:

# updatedb

  • Share/Bookmark

cPanel Log Locations

July 29th, 2010 by tech No comments »

cPanel Log File Locations

This is a shortlist of various log files for various applications on your Cpanel VPS.

cPanel Installation Logs:
/var/log/cpanel-install-thread0.log

Apache:
/usr/local/apache/logs/access_log
/usr/local/apache/logs/error_log

Apache domlogs:
/usr/local/apache/domlogs/example.com

Apache SUEXEC Logs:
/usr/local/apache/logs/suexec_log

MySQL
/var/lib/mysql/hostname.err

BIND (named) Log:
/var/log/messages

Exim
/var/log/exim_mainlog
/var/log/exim_paniclog
/var/log/exim_rejectlog

Courier or Dovecot IMAP
/var/log/maillog

Tomcat Logs:
/usr/local/jakarta/tomcat/logs/catalina.err
/usr/local/jakarta/tomcat/logs/catalina.out

cPanel Access Log:
/usr/local/cpanel/logs/access_log

cPanel Error Log:
/usr/local/cpanel/logs/error_log

cPanel License Log:
/usr/local/cpanel/logs/license_log

Stats Execution Logs:
/usr/local/cpanel/logs/stats_log

ChkServd (cPanel Monitoring Daemon) Logs:
/var/log/chkservd.log

cPHulkd
/usr/local/cpanel/logs/cphulkd.log

cPanel Backup Logs:
/usr/local/cpanel/logs/cpbackup/*.log

Pure-FTP
/var/log/messages
/var/log/xferlog (symlinked to /usr/local/apache/domlogs/ftpxferlog)

Cron Logs:
/var/log/cron

SSH Logs:
/var/log/secure

ModSecurity:
/usr/local/apache/logs/modsec_audit.log
/usr/local/apache/logs/modsec_debug_log

  • Share/Bookmark

How to Install CSF

July 29th, 2010 by tech No comments »

How to install CSF (ConfigServer Security & Firewall)

# cd /usr/src/
# wget http://www.configserver.com/free/csf.tgz
# tar -xzf csf.tgz
# cd csf
# ./install.sh

(On cPanel servers, run ./install.cpanel.sh instead — it will auto-configure the ports opened).

The initial installation is complete, and you can now view the plugin at WHM >> Plugins >> “Config Server Security and Firewall”.

To configure CSF via SSH, edit /etc/csf/csf.conf and make your changes.

When your configuration is complete, you need to set the following in /etc/csf/csf.conf to disable “TESTING” mode and enable your firewall:

TESTING = “1″
to
TESTING = “0″

Lastly, restart CSF to enable all settings:

# csf -r

  • Share/Bookmark

Lowest numbered MX record points to localhost

July 29th, 2010 by tech No comments »

If you see the following in exim’s main_log:

temporarily rejected RCPT : lowest numbered MX record points to local host

This indicates that the domain doesn’t exist in /etc/localdomains. Edit the file with your favorite editor and ensure it’s listed there.

At the same time, you’ll want to ensure it isn’t listed in /etc/remotedomains.

  • Share/Bookmark

Yum rpmdb open failed

July 29th, 2010 by tech No comments »

Error: rpmdb open failed

This error occurs most frequently when the rpm database is corrupted. See below for instructions on how to rebuild the rpm database.

# yum update
Loaded plugins: fastestmirror
error: no dbpath has been set
error: cannot open Packages database in /%{_dbpath}
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 309, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 157, in main
base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 187, in getOptionsConfig
self.conf
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 664, in
conf = property(fget=lambda self: self._getConfig(),
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 239, in _getConfig
self._conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 804, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 877, in _getsysver
idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed

The most common fix is as follows:

# yum clean all
# rm -f /var/lib/rpm/__db*
# rpm –rebuilddb
# yum update

However, if this is a VZ container (VPS), the following may be required:

#mv /dev/urandom /dev/urandom.back
#mknod -m 644 /dev/urandom c 1 9

  • Share/Bookmark

Reinstall Mailman

July 29th, 2010 by tech No comments »

If you run into an issue where you need to reinstall Mailman, you can do so with the following:

# /usr/local/cpanel/bin/mailman-install --force

  • Share/Bookmark

Install chkrootkit

July 29th, 2010 by tech No comments »

How to Install chkrootkit:

# cd /usr/src
# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
# tar -xvzf chkrootkit.tar.gz
# cd chkrootkit-*/
# make sense

After that it is ready to use and you can simply type:
# ./chkrootkit

  • Share/Bookmark

cPanel Web Site Hosting by IntraHost