Using Pthread in Azure web app in a PHP site - php

I have a webapp (PHP site using CodeIgniter) hosted on Azure. I have a situation where I want to use the pthread module. Since pthread is not available in PHP out of the box, when I install it using Xampp server, I suspect that it won't be possible to use threading on Azure.
But I am not sure. Azure documentation also doesn't talk about it. Is there a way I can use it pthread on Azure?
I am able to use it on my local Windows machine, using pthread.dll.

To enable extension in Azure Web APP, we should customize PHP runtime on Azure. Please refer to official site.
For this issue,I have tried to install pthreads successfully. And I toke those steps as following:
1, I obtained a PHP 5.4 (5.4.43) VC9 x86 Thread Safe package from PHP site explored to folder named PHP. And followed the pthreads site, got the lasted version of pthreads.
2,Added pthreadVC2.dll (included with the Windows releases) to the same directory as php.exe and added php_pthreads.dll to PHP extention folder.
3,I uesd phpinfo() to find default php.ini file in Azure, which should be similar with the picture:
,
Then I browsed Kudu Console of my web app via https://<your_web_app_name>.scm.azurewebsites.net/DebugConsole/?shell=powershell.
Locate to the directory found above. Download the content to local saved as php.ini in the PHP directory. Uncommented extension_dir = "ext" in this file.
4, Add a bin directory to your root directory (for example, bin\php), and use FTP tool to upload the PHP runtime on it.
5,Browse to the web app in the Azure Portal and click the configure tab.
Add *.php to the Extension field and add the path to the php-cgi.exe executable at the Handler mappings section.
At last, we check the PHP env,we should see the result as below
and run the test code of pthreads to check the extension
If you have any concern, please feel free to let me know.

Related

How to install php thread in azure platform

I am not able to install php thread in azure. as we can not modify most of the directories and php.ini files.
I have followed the steps in this answer Using Pthread in Azure web app in a PHP site to install pthreads in Azure web app successfully with PHP 5.6 (5.6.29) VC11 x86 Thread Safe and pthreads version 2.0.9.
In which case, some additional modifications might be needed in step 3.
3, I used phpinfo() to find default php.ini file in Azure, Then I
browsed Kudu Console of my web app via
https://<your_web_app_name>.scm.azurewebsites.net/DebugConsole/?shell=powershell.
Locate the directory found above. Download the content to local saved
as php.ini in the PHP directory. Uncommented extension_dir = "ext"
in this file.
Once you have downloaded the php.ini file, change
extension_dir="D:\Program Files (x86)\PHP\v5.6\ext\" to
extension_dir = "ext".
Add the line extension=php_pthreads.dll at the end of php.ini file.
Here the pictures:
I also tried to install pthreads v3 with PHP 7, but failed. Seems pthreads v3 is NOT supported by PHP-CGI, only by CLI version. The following statement is from official site.
pthreads v3 is restricted to operating in CLI only: I have spent many
years trying to explain that threads in a web server just don't make
sense, after 1,111 commits to pthreads I have realised that, my advice
is going unheeded.
So I'm promoting the advice to hard and fast fact: you can't use
pthreads safely and sensibly anywhere but CLI.
Thanks for listening ;)
Hope this will help you. Any further concern, please let me know.

PHP Websockets extension on Microsoft Azure website

I want to use web sockets on my PHP website hosted on Microsoft Azure.
For this I need to use the websockets extension php_sockets.dll.
I added the php_sockets.dll to my wwwroot/bin folder. I edited the app settings as followed:
But I get the following error in de log:
Unable to load dynamic library 'C:\DWASFiles\Sites\mywebsite\VirtualDirectory0\site\wwwroot\bin\php_sockets.dll' - The specified module could not be found.
Is Azure blocking it?
It worked for me! Here are some things to keep in mind:
Make sure you are downloading the php_sockets.dll from the PHP for Windows site
Make sure you download the proper version (for example, I'm running PHP 5.4 on my Azure Website, so I downloaded the PHP 5.4.40 ZIP file form the page listed above).
Make sure you download the VC9 x86 Non Thread Safe package.
As you mentioned in your question, create a folder titled bin in the wwwroot folder and place the DLL in this folder.
Follow the steps in the Azure documentation: Configure PHP in web apps)

PHP, IIS, Oracle (OCI) not working

We are migrating from a Windows SBS 2011 to Windows Server 2012 R2.
We have an internal website that connects to our Oracle database using PHP.
I am trying to migrate this to the new server and so far I have:
Installed IIS Server Role
Installed PHP
Downloaded Oracle Instant Client to C:\instantclient
Added C:\instantclient to PATH System Variable
Added php_oci8.dll to php.ini and checked that PHP is actually using this php.ini
Restarted server
I am still getting error messages like oci_ commands not being recognised etc.
I'm lost. I've searched online and the instructions match what I have done from memory.
I haven't found a single thing online that I haven't done.
Depending on the version of InstantClient you have installed you might need to include the bin folder in the path, like so:
C:\instantclient\bin
To check if the DLL files are available in the path enter where oci*.dll in a command prompt. It should return a list of matching files.
Also, remember that just because your account can see the DLL files doesn't mean IIS/PHP can. That runs under a different account that might not have permission to access the files. Check your IIS error log and PHP php_errors.log file for any specific error messages.
Edit
After a rather lengthy chat, the problem was resolved by:
Updating the InstantClient from 10.1.0.5 to 10.2.0.5 (as mentioned in the module requirements: On Windows, the php_oci8 DLL needs Oracle client libraries from version 10gR2 or greater.)
Adding a copy of msvcr71.dll to the InstantClient folder.
Downloading and manually configuring PHP from php.net instead of using PHP Manager for IIS.
Ensuring the Path environment variable correctly pointed to the InstantClient and PHP folders.
try this:
extension=php_oci8_12c.dll
(instead of php_oci8.dll) - that is what I am using and you probably downloaded the same instant client as I did.

How do I install ionCube on an Azure Web Site?

I am trying to follow the instructions under Using Custom PHP Extensions in Windows Azure Web Sites to enable the ionCube extension for PHP running within an Azure Web Site. Here's what I did:
Downloaded the Windows VC9 (Non-TS) (x86) loader from the ionCube loader download page.
Created a directory at /site/wwwroot/bin
FTP'd ioncube_loader_win_5.3.dll to that directory.
Under "app settings" in the Azure portal for the web site I added PHP_EXTENSIONS with value bin/ioncube_loader_win_5.3.dll.
I loaded http://my.azure.website/info.php and verified that the Environment table included PHP_EXTENSIONS = bin/ioncube_loader_win_5.3.dll. It also contains APPSETTING_PHP_EXTENSIONS = bin/ioncube_loader_win_5.3.dll.
When I try to load the site I get the message "The page cannot be displayed because an internal server error has occurred" and no additional information.
Is there something I forgot or is ioncube not supported on Azure? Did I set up the directory properly?
I also tried the Zend Guard Loader extension (ZendLoader.dll) in the same manner. I don't get an error message, but the extension doesn't show up in phpinfo() either.
I posted an article explaining How to configure ZendGuard on Windows Azure Web Sites
You shall not put the module in the root of the ftp site. The DLL module must reside in a folder below the APPLICATION ROOT, which is site/wwwroot/ So, you have to create either site/wwwroot/bin or anything of your choice (i.e. site/wwwroot/phpext), and then map PHP_EXTENSIONS again to bin/ioncube... (or phpext/iocube...), whatever is the name of your folder underneath site/wwwroot/!
However I am having trouble running any php page when the mentioned module is enabled. I don't know whether this is because my files are not ionCube encrypted, or because of some issue with the ionCube itself. So if you have a ionCube encrypted file, you have the chance to test.
ionCube is a Zend Extension, so according to an answer on windows azure forums:
The correct way to do it would be to create the /site/wwwroot/bin directory and upload ioncube_loader_win_5.4.dll there then add under the portal App Settings a PHP_ZENDEXTENSIONS setting with bin\ioncube_loader_win_5.4.dll as its value.
I confirm, but my tests was done in /site/phpext with an App Setting on ..\phpext\ioncube_loader_win_5.4.dll.

Install PHP on XP / IIS 5.1?

I am trying to install PHP onto my development box (XP SP3 / IIS 5.1) I've got PHP 5.2.6 stable downloaded (the MSI installer package) and I am getting an error "Cannot find httpd.conf". After that the install seems to breeze by quickly (more quickly than I would have expected) and when I try to execute a simple PHP script from my localhost test directory that I created, I get a slew of missing DLL errors. I have seen posts out there which indicate that its possible and has been done. I dont see any bug reports for this MSI at PHP.NET support. Any ideas?
Not sure if you already have this but I use WAMP from http://www.wampserver.com/en
It's easy and simple to set up, it has an icon in the system tray to show that its active and you can make it go online or available to the outside by clicking the icon and setting it. I used this when I was first learning PHP since it has everything in one, no need to setup any other service like IIS.
Probably the installer didn't configure your server to use PHP properly. Check out Microsoft's page on enabling PHP on IIS or alternatively switch to Apache if that's a viable option.
I'll see if I can remember it correctly:
Unzip PHP zip file into c:\Program Files\php (or run the installer)
Copy php5ts.dll into c:\windows\system32
Copy php.ini.dist into c:\windows and rename it to php.ini
Edit c:\windows\php.ini and look for extension dir - make it point to c:\Program Files\php\extensions (or wherever you put it)
This is where my memory gets fuzzy: Edit your IIS application settings, add a script map for .php files, and set the executable to php5ts.dll
Profit!?!??!?!

Categories