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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.