I need to install on a lamp server exactly the same php extensions that are installed on an old server, how do to know exactly which extensions are installed in order to install the same on the new server?
You can use the command line switch
php to see what modules are installed.
$ php -m | head [PHP Modules] bz2 calendar ctype curl date dbase dom exif fileinfo ...
You could also use
php -i to get
phpinfo(); output via the command line which would include this info as well.
If the extension is actually being used, it will need to be referenced in
php.ini somewhere. Extensions are loaded in a pretty intuitive manner:
One thing to watch out for are extensions that are brought in by an additional
ini file being included. I'm not sure about Debian, but on RHEL there's a
/etc/php.d/ directory where all
.ini files are treated like as if they had been in the main
If it's not in one of those two places (main
php.ini or one of the included files) then the extension is more or less just sitting on the filesystem not being used.
Actually, I think I lied. You may have to look at your php files for calls to dl(). I don't know of many people who load extensions like that, though. Not even sure what the use case would be but it's another area you should probably check.
In Debian, PHP extensions are loaded via files in /etc/php5/conf.d
There are two types of PHP Debian packages that might be installed here:
- Debian PHP packages (which have names starting with php5- )
- PECL PHP packages (which have names starting with php- )
To list both on your system, you can use this command: dpkg -l | grep 'ii php5\?-' which lists installed packages starting with either php- or php5- .
You also might have extensions that were built with PECL from source code. List those with: pecl list
Finally, it's possible to compile your own extensions the old fashioned way. In that case they might not have a file in /etc/php5/conf.d but might be added to php.ini itself.
All extensions usually have a section of output from phpinfo();. php -m will show the list of what extensions PHP has loaded (each of which should have a spot in the phpinfo output). There will be many more extensions listed in the php -m output than are installed as add-on packages in Debian, because there are lots of default extensions built into PHP as well as the ones you can install afterwards.
Here is example output from a development machine listing extra installed PHP extensions:
root@zaphod:~# dpkg -l | grep 'ii php5\?-' ii php-auth-sasl 1.0.4-1 all Abstraction of various SASL mechanism responses ii php-db 1.7.14-2 all PHP PEAR Database Abstraction Layer ii php-mail 1.2.0-4 all PHP PEAR module for sending email ii php-mail-mime 1.8.4-1 all PHP PEAR module for creating MIME messages ii php-mail-mimedecode 1.5.5-1 all PHP PEAR module to decode MIME messages ii php-net-smtp 1.6.1-1 all PHP PEAR module implementing SMTP protocol ii php-net-socket 1.0.9-2 all PHP PEAR Network Socket Interface module ii php-pear 5.4.39-0+deb7u2 all PEAR - PHP Extension and Application Repository ii php-xml-parser 1.3.4-6 all PHP PEAR module for parsing XML ii php5-cgi 5.4.39-0+deb7u2 amd64 server-side, HTML-embedded scripting language (CGI binary) ii php5-cli 5.4.39-0+deb7u2 amd64 command-line interpreter for the php5 scripting language ii php5-common 5.4.39-0+deb7u2 amd64 Common files for packages built from the php5 source ii php5-curl 5.4.39-0+deb7u2 amd64 CURL module for php5 ii php5-dev 5.4.39-0+deb7u2 amd64 Files for PHP5 module development ii php5-gd 5.4.39-0+deb7u2 amd64 GD module for php5 ii php5-imagick 3.1.0~rc1-1+b2 amd64 ImageMagick module for php5 ii php5-imap 5.4.39-0+deb7u2 amd64 IMAP module for php5 ii php5-intl 5.4.39-0+deb7u2 amd64 internationalisation module for php5 ii php5-mcrypt 5.4.39-0+deb7u2 amd64 MCrypt module for php5 ii php5-mysql 5.4.39-0+deb7u2 amd64 MySQL module for php5 ii php5-pgsql 5.4.39-0+deb7u2 amd64 PostgreSQL module for php5 ii php5-sqlite 5.4.39-0+deb7u2 amd64 SQLite module for php5 ii php5-suhosin-extension 0.9.37-2 amd64 advanced protection system for PHP5 ii php5-sybase 5.4.39-0+deb7u2 amd64 Sybase / MS SQL Server module for php5 ii php5-xdebug 2.2.1-2 amd64 Xdebug Module for PHP 5 root@zaphod:~# pecl list Installed packages, channel pecl.php.net: ========================================= Package Version State APC 3.1.13 beta memcache 3.0.8 beta