Difficulty loading additional extensions into php instance on Azure - php

Trying to load one new extension to php instance on Azure. After reading several articles and tutorials, I feel that I have everything set up properly. In addition to adding the dll, I'm also telling the file to change the location of the includes/ directory. In addition, I've tried both PHP7.2 and 7.3 for the application.
That change works, so the file is getting read. But teh .dll does not show up with phpinfo nor a dump of all the loaded extensions. The fact that the .ini file I'm using also specifies a new location for the includes directory show that the file is being read properly. That does not hold true for the dll though and I don't know it I'm using the wrong version of the dll, have a poor configuration or something else.
This is my first rodeo with Azure, so it's a steep learning curve so far.
I've tried multiple variations of the details but nothing has worked yet. Currently, I have an application setting with "PHP_INI_SCAN_DIR" that points to the directory in the D drive of d:\home\site\ext.
I have another .ini file for the actual extensions in the ini directory as well. The sole line in it points at the dll location - zend_extension="d:\home\sites\ext\php_xdebug-2.7.2-7.2-vc15-nts.dll"
The path is correct and, from what I can tell, everything is right - but the extension won't load. I've changed the location, changed the file name, changed build versions of the file, used 'zend_extension' and just plain 'extension' with similar results. Using 32bit nts extensions as well.
No error messages seen - either on screen on in the logs on Azure. I expect to see xdebug as a separate section after wddx using phpinfo() but nothing shows.
Any assistance would be greatly appreciated. Thanks in advance.

It sounds like you have read the related sections of the offical document Configure PHP in Azure App Service.
However, there are some important points I think which be necessary to pay attention to.
In section How to: Change the built-in PHP configurations, notice for these steps as below.]
Add a .user.ini file to your root directory.
Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file.
Restart the app. (Restarting is necessary because the frequency with which PHP reads .user.ini files is governed by the
user_ini.cache_ttl setting, which is a system level setting and is 300
seconds (5 minutes) by default. Restarting the app forces PHP to read
the new settings in the .user.ini file.)
Add an App Setting to your app with the key PHP_INI_SCAN_DIR and value d:\home\site\ini
Create an settings.ini file using Kudu Console
(http://.scm.azurewebsite.net) in the d:\home\site\ini
directory.
Add configuration settings to the settings.ini file using the same syntax you would use in a php.ini file.
To reload the changes, restart your app.
So it's important that to create .user.ini and settings.ini files in the correct path, and to restart your app is required for reloading the changes.
In sections How to: Enable extensions in the default PHP runtime and How to: Use a custom PHP runtime, for compatibility, please use an extension with VC9 and non-thread-safe (nts) compatible version, not VC15.
Put .dll extension files in the ext directory (for example, php_xdebug.dll). Make sure that the extensions are compatible with
default version of PHP and are VC9 and non-thread-safe (nts)
compatible.
Obtain a non-thread-safe, VC9 or VC11 compatible version of PHP for Windows. Recent releases of PHP for Windows can be found here:
https://windows.php.net/download/. Older releases can be found in the
archive here: https://windows.php.net/downloads/releases/archives/.
Hope it helps.

Related

PHP version 5.5 doesn't recognize custom include_path set in php.ini file. Lower PHP version does

My website currently runs on PHP 5.2 on an Apache Linux server (according to my hosting providers info). I want to upgrade to at least PHP 5.5 since there is a feature I need available from that version and above. I am open to also use higher versions like 7, but every version above 5.2 brings the following problem:
When running in PHP 5.2 I successfully added a custom include_path additionally to the default one in the php.ini
php.ini:
[PHP]
include_path = ".:/usr/local/lib/php:/custom/include/path"
register_globals = Off
In the above php.ini code the default path which was already set is
/usr/local/lib/php
and the one I added is
/custom/include/path
(I removed personal information by changing path and file names).
I should mention that the additional include_path is not in the same folder structure. In fact, it is on a different domain. Still the same server, but a different domain, so for the additional path I have to go through the root path of my providers users/... path.
(The domains share the same website content, just in different languages. That is why I want both to be able to access and process a common main include_path since they use the same scripts).
In my website I include php files commonly just like this:
website.php:
<?php
require_once 'external_script_file.php';
?>
As I said, in PHP 5.2 everything runs smoothly. The file is loaded and processed. But as soon as I switch the PHP version up to let's say 5.5 I get this error:
Error in browser:
Warning: require_once(external_script_file.php): failed to open stream: No such file or directory in /[server_path]/website.php on line 7
Fatal error: require_once(): Failed opening required 'external_script_file.php' (include_path='.:/usr/local/lib/php') in /[server_path]/website.php on line 7
(I removed personal information by changing path and file names).
As you see in the error message, he seems to only be able to see the default include path, but not the added custom one.
Do I have to manage something differently regarding the php.ini settings file when operating in a higher PHP version? Or what else could be the issue?
Thanks a lot!
​
You can try using set_include_path() function in your code.
set_include_path('/usr/lib/pear');
Or ini_set()
ini_set('include_path', '/usr/lib/pear');
You didn't mentioned any information about the system you are trying to run PHP on (i.e. what OS, web server, etc), so this is a shot in the dark. If you have multiple PHP versions installed, it's possible that each version has its own php.ini file.
On the page you are trying to load, stick phpinfo();die; at the top of the file. Run the site in PHP 5.2, and see what the "Loaded Configuration File" value is. Then, switch to a newer PHP version, refresh the page, and check if the "Loaded Configuration File" value is the same or not.
Just an accident!
Either the php.ini generator I used, or just me copying back and forth created a space at the beginning of the php.ini file, right before the title [PHP]. Apparently PHP versions higher than 5.2 can't handle that.
So just make sure to not create any unneccessary spaces within, or especially at the beginning of the php.ini file.

Cannot load imagick library

I have installed the imagick from here (ImageMagick-7.0.3-1-Q16-x64-dll) and the dll (TS 32 bit) from here. And also copiend the CORE_RL_* to the C:\xampp\apache\bin BUT still i get the following error when i run the laravel server.
ERROR: Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_imagick.dll' - The specified module could not be found.
in Unknown on line 0
Also, I placed dll file in C:\xampp\php\ext\php_imagick.dll.
Also, the imagick is shown in the phpinfo().
And when i use it using laravel i get the following error.
getting Imagick to work on Windows has always been a bit hit and miss as pointed out here is a good guide
http://stackoverflow.com/a/36378764/1090867
But it misses an important point
You do not need to put the binary into the PHP folder!
So here are the steps I follow myself every time I need to do this. This should work for apache, Nginx, or IIS.
Step 1
find out your php version and setting
You need to version, Architecture, Compiler and Thread Safety
if Thread Safety is disabled this is NTS is enabled it will TS
Step 2
Get and install a copy of ImageMagick and make sure it matches your Architecture, this also needs to be dll.exe rather than the static version.
Regarding Q8 and Q16 I'll leave that to you but both versions will work
Link
I recommend changing the install directory name to something generic like
C:\Imagemagick since I've had some problems in the past with the default directory name with PHP and windows.
Just install but make sure you tick add application path and I normally tick the legacy utils as well.
Once it's installed go to your environment variables and make sure it is actually in the path. There is no need to copy anything to your PHP folder
Just to make sure everything is working open the command line and type convert --version you should get a response
Step 3
This unfortunately is the hard part and can be a bit of trial and error. I've found the following provides the best php_imagick.dll that seems to work 9 times out of 10
http://www.peewit.fr/imagick/
Just pick the version that matches your install.
If this doesn't work then go to php.net and try each version until one works... (start at the latest)
http://windows.php.net/downloads/pecl/releases/imagick/
Once you have a php_imagick.dll put it into your php/ext/ folder
thne locate your php.ini file go to the bottom (or whereever your extensions are) and add extension=php_imagick.dll
Step 4
Restart PHP (or your computer) and it should be working if not try a different php_imagick.dll and repeat.
If the above doesn't work
Then try a slightly older version of Imagick I normally use version 6.8.6-8 Q16.
Please note I've only ever really done this on Windows 7 and Windows Server 2008, 2008 R2, 2012, and 2012 R2 all x64 with x86 PHP
If this still doesn't work then you probably need to copy over the CORE_RL files into your Imagick directory this normally causes more issues but if you are running out ideas then give it a go
I just ran into this issue. Only I'm using PHP on the command line (PHP CLI). The problem is the dependencies that the main php_imagick.dll file has. PHP will attempt to load the extension but since Windows can't find the CORE_RL_ DLLs, the extension will fail to load and the error/warning message about being unable to load the DLL will appear. It helps to know how Windows loads DLLs:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx
It's pretty convoluted but you can see that the reason the Apache /bin directory trick works with Apache is that httpd.exe is located in that directory. However, when using PHP CLI, the DLLs need to be located in the same directory as php.exe.
If you don't want duplicate DLLs floating around, add the directory containing php.exe to the system PATH and plop all the CORE_RL_ DLLs there. The PATH is the last thing searched, but it'll work fine. If you don't want spurious entries in your system PATH, then set the extra PATH information only during startup of Apache.
This is because the dependencies are missing. Those who are facing the same error Unable to load dynamic library 'php_imagick', Please follow the below steps
Go to https://pecl.php.net/package/imagick choose a stable version and click on the DLL link.
From the DLL list click the link which, is suitable for your PHP version.
After downloading the php_imagick zip file, extract it and copy the php_imagick.dll file to C:\xampp\php\ext folder.
Extract all DLL files from the php_imagick zip file (except php_imagick.dll) to the PHP root directory (where you have php.exe). Ex: For XAMPP user C:\xampp\php folder.
Add extension=php_imagick to your php.ini file.
Restart the Apache server.
Things to keep in mind before choosing from the DLL list.
Check the PHP version.
Check the architecture (x64/x86).
Check Thread Safety (enabled/disabled).
N.B: Above solution is for XAMPP users only.
I changed php_imagick in php.ini file to php_imagick.dll and it happened
I had the same problem. It turns out I have to install complete ImageMagic application, not just ImageMagic php extension.
And I also set MAGICK_HOME environment variable.

GD2 library in PHP not installing

I'm having problems installing the GD library. I'm using an IIS server with PHP 5.2.14. I uncommented extension=php_gd2.dll in php.ini.
This is the error:
gd: Unable to initialize module
Module compiled with module API =20060613
PHP compiled with modlule API = 20090626
These options need to match
in Unknown on Line 0
I downloaded various PHP versions to try and get the correct DLL, including thread-safe 5.2.14. I would then restart my application pool and try to load a file that uses the GD library. Are there other files necessary for gd2 to work? Are there any quick ways to solve this without reinstalling PHP entirely?
first, iis7 was not configured properly for php - I searched for a guide that walked me through. Second the directory was incorrect, whenever I reset the iis server it originally would say one directory when ISAPI api was being used- but after 2 mins it would say extension_dir was in another directory when cgi/fastcgi is being used. So i created that directory that it wanted (which was different than any of my php.ini's). The one it was pulling from needed to be put in the C:/windows directory, but even though I had it set to go to "./ext" it wanted to go to Program files/PHP-- extremely weird. Third, I had to add IUSR to the permissions of any folder being used.

PHP won't parse MySQL statements

I just installed Apache 2.2.15/PHP 5.3.2/MySQL 5.1.44 on Windows Vista. Apache is working fine, PHP is functional, and MySQL works on the CLI. However, when I try to access MySQL via PHP, I get an error (Fatal error: Call to undefined function mysql_connect()). extension=php_mysql.dll and extension=php_mbstring.dll are uncommented in the php.ini file, and PHP is in the system path. There is no libmysql.dll in either the top level PHP directory or the ext directory. There's a libmySQL.dll file in the MySQL bin directory (which is also in the system path); I tried renaming it, but that doesn't do anything
Also, in case anyone wants to know, I originally installed PHP using the MSI installer, but it was missing some DLLs, so I installed from the zip file.
I think I've exhausted all my options. Any help on this problem would be very appreciated.
Thanks in advance.
IIRC the msi installer sets some registry values that influence the php configuration, see http://docs.php.net/configuration.changes#configuration.changes.windows. That might change the location of the php.ini that is used. You might want to delete those registry keys. Anyway, you did edit the file that is shown in the output of phpinfo()?
Which build of php do you use? The one you can download from http://windows.php.net/download/? Then you probably have the new mysqlnd transport driver built into the php core dll and don't need libmysql.dll. The mysqlnd driver should show up in the output of phpinfo(). Does it?
It sounds like you do not have the MySQL mod for PHP properly installed or configured. I recommend using AMP on Linux, so sorry for not having any specific instructions for Windows.

php_dio & php_win32service won't work on wamp server 2.5

I'm trying to use php_dio & php_win32service because I want to query COM10 on my server using php and also get status & restart some of my win services.
Although I'm using the correct dlls (for PHP 5.5 X64 thread safe) I keep getting warning icon on the extensions and there is no error on php log.
I'm clueless what can be done.
please advise.
The Warning icon is presented in that menu for 2 possible reasons
The extension=php_xxx.dll exists in the php.ini file but the dll does not exist in the \ext folder.
The dll exists in \ext folder but the extension=php_xxx.dll line does not exist in the php.ini file.
So which did you forget to do?
Also remember there are 2 php.ini files :-
The one in \wamp\bin\php\php{version}\php.ini is used by PHP CLI only
The one you can edit using the wampmanager->PHP->php.ini menus which is used by when running under Apache.
You say you have used the correct dll's but just to be sure for WAMPServer 2.5 using Apache2.2.9 you need the Thread Safe + VC11 compiled versions

Categories