271

I have been meaning to install ffmpeg as an extension to my PHP setup. So before I can install it, I need to phpize it. I installed php5-dev by sudo apt-get install php5-dev. But now when I run phpize I get the following error :

phpize
Cannot find config.m4. 
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

The location of my php.ini is /usr/local/zend/etc/php.ini

From another online resource I tried this

sudo apt-get install autoconf automake libtool m4

But all of them are already installed.

Locate config.m4 didn't return anything.

Any pointers here how I can get phpize and thus, ffmpeg up and running?

CerebralFart
  • 3,336
  • 5
  • 26
  • 29
Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74

18 Answers18

593

For recent versions of Debian/Ubuntu (Debian 9+ or Ubuntu 16.04+) install the php-dev dependency package, which will automatically install the correct version of php{x}-dev for your distribution:

sudo apt install php-dev

Older versions of Debian/Ubuntu:

For PHP 5, it's in the php5-dev package.

sudo apt-get install php5-dev

For PHP 7.x (from rahilwazir comment):

sudo apt-get install php7.x-dev

RHEL/CentOS/yum

yum install php-devel # see comments
Felix
  • 4,510
  • 2
  • 31
  • 46
Blackout
  • 5,954
  • 1
  • 14
  • 2
84

For PHP7 Users

7.1

sudo apt install php7.1-dev

7.2

sudo apt install php7.2-dev

7.3

sudo apt install php7.3-dev

7.4

sudo apt install php7.4-dev

If not sure about your PHP version, simply run command php -v

M_R_K
  • 5,929
  • 1
  • 39
  • 40
  • 15
    you don't really need to type apt-get anymore. apt install is the same. apt-cache no longer needs to be typed anymore either just apt search – Kevin Remisoski Sep 13 '16 at 22:06
  • php7.0-dev is not found in the package list for me. Weird, I see php5-dev in the list, but no php7.0 packages at all. – Solomon Closson Aug 20 '17 at 02:08
  • @SolomonClosson It depends on the OS version you use. – M_R_K Aug 20 '17 at 03:26
  • 1
    If you install package php-dev instead, PHP will always upgrade to the latest stable release. If you install php7.0-dev and PHP 7.1 is released, you generally won't be upgraded to it. – MacroMan Oct 17 '18 at 13:16
  • 1
    Could you update your answer and add the solution for PHP 8? Now that PHP8 alpha 1 is here... – 7ochem Jun 29 '20 at 09:39
29

Ohk.. I got it running by typing /usr/bin/phpize instead of only phpize.

Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74
  • 8
    In which case /usr/bin is not in your PATH, but I'm guessing it should be. Do `PATH=$PATH\:/usr/bin; export PATH`, and `phpize` will work in the future. – Berry Langerak Jan 13 '12 at 09:36
  • I got this error message "ffmpeg shared libraries not found. Make sure ffmpeg is compiled as shared libraries using the --enable-shared option" I am using this command "phpize" it is working but whene I am running this "./configure && make" this error comes – Chintan Gor Aug 27 '14 at 06:28
16

Under Redhat Enterprise / CentOS, use yum to install the php-devel module:

yum install php-devel

For PHP 7, you need:

yum install php70-php-devel
fedorqui
  • 275,237
  • 103
  • 548
  • 598
9

Step - 1: If you are unsure about the php version installed, then first run the following command in terminal

php -v

Output: the above command will output the php version installed on your machine, mine is 7.2

PHP 7.2.3-1ubuntu1 (cli) (built: Mar 14 2018 22:03:58) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3-1ubuntu1, Copyright (c) 1999-2018, by Zend Technologies

Step 2: Then to install phpize run the following command, Since my php version is 7.2.3. i will replace it with 7.2, so the command will be,

sudo apt-get install php7.2-dev

Step 3: Done!

Alternate method(Optional): To automatically install the phpize version based on the php version installed on your machine run the following command.

sudo apt-get install php-dev

This command will automatically detect the appropriate version of php installed and will install the matching phpize for the same.

Manoj Selvin
  • 2,247
  • 24
  • 20
8

Hmm... actually i dont know how this solved it? But the following steps solved it for me:

find / -name 'config.m4'

Now look if the config.m4 is anywhere in a folder of that stuff you want to phpize. Go to that folder and run phpize directly in there.

Jerry U
  • 618
  • 9
  • 22
Bosh
  • 1,237
  • 1
  • 16
  • 23
6

For ubuntu 14.04LTS with php 7, issue:

sudo apt-get install php-dev

Then install:

pecl install memcache
fedorqui
  • 275,237
  • 103
  • 548
  • 598
pingle60
  • 726
  • 7
  • 9
  • 1
    please wrap your code bits with backticks so that it is displayed as code – YakovL Sep 06 '16 at 12:52
  • 1
    Actually, using just php-dev will install the version currently released and maintained for your distro. So on Ubuntu 12 it will install php5-dev. – MacroMan Dec 22 '17 at 11:47
5

In Ubuntu 16.04, you can install phpize with the command

aptitude install php7.1-dev // for php 7.1

which is equivalent to

apt-get install php7.1-dev // for php 7.1
Donnie Ashok
  • 1,355
  • 1
  • 11
  • 26
num3ri
  • 822
  • 16
  • 20
5

If you're having problems with phpize not found on CentOS7.x after you have installed the relevant devel tools for your version/s of PHP, this path finally worked for me:

For PHP 7.2.x

/opt/cpanel/ea-php72/root/usr/bin/phpize

For PHP 7.3.x

/opt/cpanel/ea-php73/root/usr/bin/phpize

For PHP 7.4.x

/opt/cpanel/ea-php74/root/usr/bin/phpize

Run this in your folder containing the downloaded PHP extension, for example in line 3 below:

Example based on installing the PHP v7.3.x Brotli Extension from https://github.com/kjdev/php-ext-brotli

git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd /php-ext-brotli
/opt/cpanel/ea-php73/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config
make
make test
Invisionary
  • 61
  • 1
  • 5
2

Install from linux terminal

sudo apt-get install <php_version>-dev

Example :

sudo apt-get install php5-dev     #For `php` version 5
sudo apt-get install php7.0-dev   #For `php` version 7.0
Sumon Sarker
  • 2,707
  • 1
  • 23
  • 36
2

Of course in PHP7.2

sudo apt-get install php7.2-dev
HMagdy
  • 3,029
  • 33
  • 54
1

This might help someone on ubuntu. No promises.

sudo apt-get install libcurl3 php5-dev libcurl4-gnutls-dev libmagic-dev
sudo apt-get install php-http make
sudo pecl install pecl_http

And adding "extension=http.so" to php.ini (Normally located at /etc/php5/apache2/php.ini)

Then restart Apache (sudo service apache2 restart).

If in doubt, check your apache logs:

sudo su --
cd /var/log/apache2
tail -25 error.log

Is http.so starting or failing?

ted.strauss
  • 4,119
  • 4
  • 34
  • 57
1

For ubuntu with Plesk installed run apt-get install plesk-php56-dev, for other versions just change XX in phpXX (without the dot)

Paul Chu
  • 1,249
  • 3
  • 19
  • 27
Sanel
  • 31
  • 3
1

For instance, if you wanted to use the "phpize" command for PHP 5.6, you would use the full path: Code:

/opt/cpanel/ea-php56/root/usr/bin/phpize
Shobhit Verma
  • 794
  • 8
  • 25
0

Go to the downloaded folder and there you find config.m4. Open the terminal and run phpsize.

0

I had this exact problem on macOS in 2018.

For me, first running brew install php before sudo pecl install mongodb did the trick.

Pang
  • 9,564
  • 146
  • 81
  • 122
Adam Diament
  • 4,290
  • 3
  • 34
  • 55
  • Two things on this old answer... 1) You should also include the instructions on how to install `brew` in the first place (get Command Line utilities, go to https://brew.sh and get it, beware of destroying your Apple-installed PHP, etc.); also note that Linux users _can_ use `brew`, too! 2) `pecl` will obviously only install PECL packages, the OP was interested in `ffmpeg-php`, which is _not_ available via PECL at all... – Gwyneth Llewelyn Dec 22 '21 at 01:15
0

You didn't specify what operating system you're using, and 90% of the answers assume Ubuntu/Debian Linux because of the apt-get install autoconf automake libtool m4 command that you posted (and over half expect you to be running CPanel), so I'm giving you a slightly more generic solution which ought to work on any Un*x clone (including Microsoft's WSL!).

You will need at least a few prerequisites:

  1. A working C/C++ compiler — GCC or clang being the most popular options these days.
  2. A 'developer edition' of PHP, which some package managers call 'development headers'. In the case of aptitude, as shown on the other answers, you ought to be fine with just sudo apt install php-dev. Beware of the mentioned caveats: you might end up with a slightly more unstable version of PHP which might not be updated correctly with future versions.
  3. These days (that's late 2021 for me!), for those running Ubuntu, and wishing to seriously tinker with PHP, the recommendation is to use Ondřej Surý's personal package archive for PHP. Ondřej keeps his PPA always up to date, sometimes within a few hours after release; he keeps up with the latest four Ubuntu distributions and all the currently supported PHP versions that haven't reached end-of-life status yet (sorry, PHP5 is considered completely obsolete and plagued with unpatched bugs and security issues, so it's not supported — for very good reasons!); and he provides a lot of PHP extensions, too. Sadly, ffmpeg-php is not one of them...
  4. There is a good reason for the overall lack of support of ffmpeg-php. Allegedly, the original repository for that was hosted at Sourceforge but has been abandoned in 2007. The recommended package these days is PHP-FFMpeg which is constantly being updated, and ought to be easily installed using composer — get it before starting your compilation!

Alternatively, instead of relying on an external non-official PHP extension (albeit one that is both popular and updated regularly!), you ought to launch the ffmpeg binary using shell_exec(). This is the officially recommended approach, mostly because converting videos always takes a long time, and the authors of that recommendation suggest a simple architecture where the PHP script basically launches ffmpeg in the background, accepting batches of videos for processing. The page is a bit old, but the technique shown is sound.

Gwyneth Llewelyn
  • 796
  • 1
  • 11
  • 27
0

I am using XAMPP on Linux mint and it is by default installed if your don't have

sudo apt-get install php7.0-dev
// or
sudo apt-get install php-dev

know more

MD SHAYON
  • 7,001
  • 45
  • 38