Using Pthread in Azure web app in a PHP site

穿精又带淫゛_ 提交于 2020-01-03 05:16:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31536254/using-pthread-in-azure-web-app-in-a-php-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!