Archive for the ‘PHP’ category

How to Install ffmpeg

September 1st, 2010

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

PHPInfo

April 22nd, 2010

PHPInfo pages can be useful when needing to verify what php modules are installed/loading properly, or to see which php.ini a site is using.

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

http://us3.php.net/phpinfo

Share

How to Install EAccelerator, IonCube, Zend Optimizer, SourceGuardian, and SuHosin outside of EasyApache

April 10th, 2010

Many don’t know that you don’t need to run EasyApache to install EAccelerator, IonCube Loader, Zend Optimizer, SourceGuardian, or SuHosin. Why waste your time?

You can use /scripts/phpextensionmgr to install or uninstall these modules!

# /scripts/phpextensionmgr list
Available Extensions:
EAccelerator
IonCubeLoader
Zendopt
SourceGuardian
PHPSuHosin

So, if you wanted to install Zend Optimizer, you’d run:

# /scripts/phpextensionmgr install Zendopt
Installing Zendopt
Determining PHP version
Installing Zend Optimizer binary
Activating Zend Optimizer in /usr/local/lib/php.ini
Zend Optimizer activated
Skipping install to /usr/local/php4, missing php.ini

Easy peasy. :)

Share

Modifying your PHP Handler Configuration via SSH

April 10th, 2010

Your PHP handler and SuExec configuration can be modified in WHM >> Apache Configuration >> PHP and SuExec Configuration, but if you’d like to make your change via SSH, you can use rebuild_phpconf.

Note: with this utility, you can not add new handlers, or enable an alternate PHP version if it’s not installed. You’d need to use EasyApache to enable that change.

What’s my current configuration?
# /usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled

Let’s say I wanted to switch to DSO, keeping PHP4 disabled, and SuExec enabled:
# /usr/local/cpanel/bin/rebuild_phpconf 5 none fcgi 1

For reference, the usage details:
Usage: /usr/local/cpanel/bin/rebuild_phpconf [--dryrun] [--no-restart] [--no-htaccess] [--current|--available]
--dryrun : Only display the changes that would be made
--no-restart : Don't restart Apache after updating the php.conf link
--no-htaccess : Don't update user configurable PHP mime mapping.
--current : Show current settings
--available : Show available handlers and PHP SAPIs
: Version of PHP to set as default handler for .php files
: Type of Apache module to use in serving PHP requests
: enabled, disabled, 1 or 0

Share

Install SSH2 for PHP

October 16th, 2009
wget http://downloads.sourceforge.net/project/libssh2/libssh2-1.2.1.tar.gz?use_mirror=softlayer
 tar -zxvf libssh2-0.12.tar.gz
 cd libssh2-0.12
./configure && make all install

Run the pear installer for PECL/ssh2:

pear install ssh2

If this installing via pear fails,

wget http://pecl.php.net/get/ssh2-0.11.0.tgz
 tar -zxvf ssh2-0.11.tgz
 cd ssh2-0.11
 phpize && ./configure --with-ssh2 && make

Copy ssh2.so to /usr/local/lib/php/extensions/no-debug-non-zts-20020429.

 cp modules/ssh2.so /usr/local/lib/php/extensions/no-debug-non-zts-20020429

Add extension=ssh2.so to /usr/lib/php.ini
Run service restart httpd to enable these changes.

Share

Horde – Fatal error: Call to undefined method Registry::hasInterface() in /usr/local/cpanel/base/horde/config/prefs.php on line 134

September 28th, 2009

Fatal error: Call to undefined method Registry::hasInterface() in
/usr/local/cpanel/base/horde/config/prefs.php on line 134

If you are using the Turkish language in Horde, you may want to utilize English, if at all possible, due to a bug in PHP 5.2 which will not be resolved until PHP 6.

http://bugs.php.net/bug.php?id=35050

Share

Roundcube hangs when sending mail

September 27th, 2009

In recent builds of roundcube, you may find that you can’t send mail using Roundcube. If /var/cpanel/roundcube/log/errors shows the following:


[30-Jan-2009 14:07:11] Invalid response code received from server (421):
[30-Jan-2009 14:07:11] Invalid response code received from server (-1):
[30-Jan-2009 14:07:34 -0800] SMTP Error: SMTP error: Authentication failure: STARTTLS failed (Code: ) in /usr/local/cpanel/base/3rdparty/roundcube/program/steps/mail/func.inc on line 1248 (POST /3rdparty/roundcube/index.php?_task=mail&_action=send)
[30-Jan-2009 14:10:29] STARTTLS failed ():

Then there is an issue with the most recent Net-SMTP PHP module. To resolve this, edit the following file:


/usr/local/cpanel/base/3rdparty/roundcube/config/main.inc.php

and change

// SMTP username (if required) if you use %u as the username RoundCube
// will use the current username for login
$rcmail_config['smtp_user'] = '%u';

to this:


// SMTP username (if required) if you use %u as the username RoundCube
// will use the current username for login
$rcmail_config['smtp_user'] = '';

Share

suphp 500 error, Premature end of script headers

September 26th, 2009


[Sat Sep 26 22:02:33 2008] [error] [client 111.222.333.444] Premature end of script headers: phpinfo.php
[Sat Sep 26 22:02:33 2008] [error] [client 111.222.333.444] File does not exist: /home/username/public_html/500.shtml

First step: ensure that you’re using proper permissions on your files for suphp. Your php files should have 644 permissions, and ownership of the user whose home folder the files are in.

If ownership and permissions are correct, it could be a memory issue. I’ve found that some users who experience this error are running out of available memory for php to execute properly. You can try switching your PHP handler to cgi or fcgi, which will actually display an “out of memory” error in apache’s error_log, but suphp will not.


[Sat Sep 26 08:48:02 2009] [error] [client 111.222.333.444] Premature end of
script headers: php5
[Sat Sep 26 08:48:02 2009] [error] [client 111.222.333.444] File does not exist:
/home/username/public_html/500.shtml
[Sat Sep 26 08:48:02 2009] [error] [client 111.222.333.444] Out of memory

If you do have available RAM, but PHP isn’t able to use it, try increasing the RLimit value in httpd.conf and see if your script will execute then. If you look at “free” and you don’t have much free memory, you may need to upgrade your server or VPS.

Share

cPanel Web Site Hosting by IntraHost