Yesterday, I came across a library called ming for php which can do wonders while converting videos to .swf (flash), images to .swf and much more. The best thing is that ming provides wrappers in C/C++/PHP/Python/Perl/Tcl etc. So, can be used within any one of these languages. But, the damn thing drove me crazy while installing. It was very tough experience installing it as the available howtos didn’t help much. But finally I somehow managed with the installation and it worked 🙂 So, I thought of writing this how to, so that anyone having the same problem can find it helpful.
Here is a complete howto on installing php-ming in Fedora. (I installed it on Fedora 7 and with php5, but howto is supposed to work with other versions as well.) Though there are rpms available for earlier versions of ming, but I wanted the latest, so installed from source.
libming : http://www.libming.net/
PHP : http://php.net/
First of all make sure that you have php-devel package, otherwise you will not be able to install ming at all. Do the following as root.
[root@bordeaux root]# rpm -q php-devel [Enter]
If the above command says php-devel is not installed, then fetch php-devel for your php version from here and install as given below, else proceed to step 2.
[root@bordeaux root]# rpm -hiv php-devel-5.2.2-3.i386.rpm [Enter]
Download latest version of ming from here.
Untar the downloaded package.
[saini@bordeaux saini]# tar -xvzf ming-0.4.0.beta5.tar.gz [Enter]
Change directory to ‘./ming-0.4.0.beta5’ and issue ./configure and make as given below
1 2 3 4
[saini@bordeaux saini]# cd ming-0.4.0.beta5 [Enter] [saini@bordeaux ming-0.4.0.beta5]# ./configure --enable-cXX --enable-php [Enter] [saini@bordeaux ming-0.4.0.beta5]# make [Enter] [root@bordeaux ming-0.4.0.beta5]# make install [Enter] (as root)
Go to ‘./php_ext’ directory and issue ‘make’ and ‘make install’.
1 2 3
[saini@bordeaux ming-0.4.0.beta5]# cd php_ext [Enter] [saini@bordeaux php_ext]# make [Enter] [root@bordeaux php_ext]# make install [Enter] (as root)
Open make_modules.sh in your favorite editor and uncomment the line ‘make install’ and run make_modules.sh.
[root@bordeaux php_ext]# bash make_modules.sh [Enter] (as root)
Go to ‘./tmp/modules/’ directory and copy ming.so to ‘/usr/lib/php/modules/’
[root@bordeaux php_ext]# cd tmp/modules/ [Enter] [root@bordeaux modules]# cp ming.so /usr/lib/php/modules/ [Enter] (as root)
If ming.so is not found in ‘php_ext/tmp/modules/, then update your db using ‘updatedb’ and locate ming.so and if found on locate, then copy it to ‘/usr/lib/php/modules/’. If not found at all, try recompiling or issue some random commands related to make.
Go to ‘/usr/local/lib/’ and check if libming.so, libming.so.0 etc. are present there. If yes proceed else I don’t know what to do 🙁
Go to ‘/usr/lib/php/modules/’ and issue these commands.
1 2 3 4
[root@bordeaux modules]# ln -s /usr/local/lib/libming.so libming.so (as root) [root@bordeaux modules]# ln -s /usr/local/lib/libming.so.0 libming.so.0 (as root) [root@bordeaux modules]# ln -s /usr/local/lib/libming.so.0.3.0 libming.so.0.3.0 (as root) [root@bordeaux modules]# ln -s /usr/local/lib/libming.so.0.4.0 libming.so.0.4.0 (as root)
Go to ‘/usr/lib/’ and issue these commands.
1 2 3 4
[root@bordeaux lib]# ln -s /usr/local/lib/libming.so libming.so (as root) [root@bordeaux lib]# ln -s /usr/local/lib/libming.so.0 libming.so.0 (as root) [root@bordeaux lib]# ln -s /usr/local/lib/libming.so.0.3.0 libming.so.0.3.0 (as root) [root@bordeaux lib]# ln -s /usr/local/lib/libming.so.0.4.0 libming.so.0.4.0 (as root)
Restart the httpd service by issuing the command below
[root@bordeaux root]# service httpd restart [Enter] (as root)
Write a file ‘/var/www/html/info.php’ with following contents
and point your web browser to http://localhost/info.php . Now search for ‘ming’ and check whether its enabled or not.
If enabled, yes you have successfully installed php-ming 🙂 Hope this helps.
9 thoughts on “How To: Install PHP-Ming”
I might add in my case (centos5) I added a new text file ming.ini with content:
To directory /etc/php.d/
(then restart apache)
Great tutorial! Thank you very much.
Install works, but production fails
However: once I instantiate a movie like so :
$m = new SWFMovie();
$m->setBackground(0xff, 0xff, 0xff);
$i = $m->add($p);
$m->add(new SWFAction("/box.x += 3;"));
$m->add(new SWFAction("gotoFrame(0); play();"));
PHP complains on the last line about a syntax error.:
[Wed Apr 30 14:28:26 2008] [error] [client 127.0.0.1] PHP Fatal error: SWFMovie::output() [function.SWFMovie-output]: \n/\n^\nLine 1: Reason: ‘syntax error’\n in /usr/plotus/people/htdocs/js/widgets/ming2.html on line 39
what do we do now?
I think $m->save(‘file.swf’) is the right function to use.
An example working code.
$s = new SWFShape();
$s->setLine(40, 0x7f, 0, 0);
$s->setRightFill($s->addFill(0xff, 0, 0));
$s->drawCurveTo(1200, 600, 200, 200);
$m = new SWFMovie();
BTW, I edited your comment so that it looks good 🙂
Hope this example helps.
Your post saved me tons of time.
Also thank Google for digging your post out for me 🙂
i spent 5 hours on binding ming with php – eventually your tutorial helped me to figure it out properly what was wrong. 😀 thnks a lot.
The package for installa php4-ming extension don’t exist in repository of Ubuntu. What i do?
its an archived package and will not be found in the ubuntu archive… Download from the link mentioned in the howto.
Hey! I’ve been looking for a site that has some good information on Php Flash 5 Form Tutorial. I was searching around on Google and your post regarding How to install php-ming in Fedora caught my attention .. Good info thanks Sunday
Comments are closed.