I'm trying to build a bash script to install the Source Guardian PHP extension however the destination directory is different on every subsequent release of Ubuntu.
Installing PHP5 on Ubuntu 14.04 results in the extensions being stored in /usr/lib/php5/20121212+lfs/, in Ubuntu 15.04 this directory changes, e.g. /usr/lib/20131226/
I've checked /etc/php5/fpm/php.ini and /etc/php5/fpm/php-fpm.conf but neither of these files has any mention of 20121212+lfs or 20131226.
If I place the Source Guardian extension anywhere else, it does not load.
Is there a way to programmatically determine the extension folder?
asked Feb 20, 2016 at 16:18
IsometricIsometric
3211 gold badge2 silver badges6 bronze badges
Maybe you should do this:
php-config --extension-dir
If php-config
doesn't exist, then apt-get install php-config
if Ubuntu/Debian or yum install php-config
if CentOS/Red Hat]
That command will give exact location of your php
extension folder.
Don't
forget to change your php.ini
in order to use extensions.
Jeff Schaller♦
64.2k33 gold badges104 silver badges235 bronze badges
answered Apr 25, 2016 at 18:04
2
You can use this
php -i | grep extension_dir
answered Sep 18, 2017 at 13:22
1
You can search for the xdebug file extension: find $[php -r 'echo ini_get["extension_dir"];'] -type f -name 'xdebug.so'
Or just get the value: php -r 'echo ini_get["extension_dir"];'
answered Mar 23, 2021 at 12:40
You can find it as well by
creating a phpinfo script [a file that invokes phpinfo[];
] and then run it in the browser.
See the example below.
answered Apr 11, 2019 at 15:07
JulianJulian
1113 bronze badges
Just wanted to add that although
php-config --extension-dir
would give you the extension directory but usually we modify some extension location in the active php.ini file. [there can be more than one php versions installed on the system at the same time. And current php.ini file location could be found by looking to the output of phpinfo function; using finding php.ini in the output of phpinfo function].
For example, xdebug might be located in the some other folder than the extension directory using the variable zend_extension; mostly located at the end of the php.ini file.
zend_extension=/usr/lib/php/20170718/xdebug.so
So be careful when replace module file in the directory; [had made be nuts once; because although i was changing the file but was not actually reflected in the output of phpinfo file].
answered Oct 22, 2020 at 8:45
Loading or identifying extension directory of dll in windows
PHP stores all the dlls inside the extension directory in window system. The dlls are loaded from here [ the directory ] based on the setting of php.ini file. Many times one can get the error message saying extension not found. So after installation of PHP the best way to identify the extension directory is to open php info file and check for all the settings.In the php info display it will be written where the extension file of the system is stored. It is also known as extension_dir . The picture below is the screen shoot of the php info display and the portion explaining the extension directory is shown.
The php.ini file located inside windows folder [ or inside php folder ] can be edited to change the extension directory location. The location of php.ini file also can be collected from php info display. Inside the php.ini file there is a line saying like this. ; Directory in which the loadable extensions [modules] reside.
extension_dir = "c:\php_new\ext"
Change the above line to point to correct extension directory path. After showing the path inside php.ini file below the above
line there will be all dlls listing and any dll can be added or removed by commenting or removing the comment before it. Here is some listing examples. ;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
You can see three .dlls are in use. The comments lines are removed. This is the way we add or remove extensions for PHP. Checking extension loaded or not
We can check the status of the extension by using extension_loaded[] function. Here is a sample code to check gd extension.
Note that these all are in window platform.
- ini_loaded_file[]:Path of php.ini file
- Introduction to PHP
- Collect all PHP settings by phpinfo[]
This article is written by plus2net.com team. //www.plus2net.com