在PHP网站中的Azure Web应用程序中使用Pthread [英] Using Pthread in Azure web app in a PHP site

查看:84
本文介绍了在PHP网站中的Azure Web应用程序中使用Pthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure上托管了一个webapp(使用CodeIgniter的PHP站点).我有一种情况要使用pthread模块.由于pthread在开箱即用的PHP中不可用,因此当我使用Xampp服务器安装它时,我怀疑无法在Azure上使用线程.

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.

但是我不确定. Azure文档也没有讨论它.有什么方法可以在Azure上使用pthread吗?

But I am not sure. Azure documentation also doesn't talk about it. Is there a way I can use it pthread on Azure?

我可以使用pthread.dll在本地Windows计算机上使用它.

I am able to use it on my local Windows machine, using pthread.dll.

推荐答案

要在Azure Web APP中启用扩展,我们应该在Azure上自定义PHP运行时.请参考官方网站.

To enable extension in Azure Web APP, we should customize PHP runtime on Azure. Please refer to official site.

对于这个问题,我尝试成功安装pthreads.我将这些步骤执行如下:

For this issue,I have tried to install pthreads successfully. And I toke those steps as following:

1,我从 PHP网站获得了一个PHP 5.4 (5.4.43) VC9 x86 Thread Safe程序包,并浏览了名为PHP的文件夹.然后跟随 pthreads网站,获得了pthreads的最新版本.

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,将pthreadVC2.dll(Windows发行版随附)添加到与 php.exe 相同的目录,并将 php_pthreads.dll 添加到PHP扩展文件夹.

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,我会phpinfo()在Azure中找到默认的 php.ini 文件,该文件应与图片相似: ,

3,I uesd phpinfo() to find default php.ini file in Azure, which should be similar with the picture: ,

然后,我通过 https://<your_web_app_name>.scm.azurewebsites.net/DebugConsole/?shell=powershell 浏览了Web应用程序的Kudu控制台.

Then I browsed Kudu Console of my web app via https://<your_web_app_name>.scm.azurewebsites.net/DebugConsole/?shell=powershell.

找到上面的目录.将内容下载到本地,另存为PHP目录中的 php.ini .在该文件中未注释extension_dir = "ext".

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,在您的根目录中添加一个bin目录(例如bin \ php),并使用FTP工具在其上上传PHP运行时.

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,浏览到Azure门户中的Web应用程序,然后单击配置选项卡. 将*.php添加到扩展名"字段,并在处理程序映射部分中将路径添加到php-cgi.exe可执行文件.

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.

最后,我们检查PHP env,我们应该看到如下结果

At last, we check the PHP env,we should see the result as below

并运行pthread的测试代码以检查扩展名

and run the test code of pthreads to check the extension

如果您有任何疑问,请随时告诉我.

If you have any concern, please feel free to let me know.

这篇关于在PHP网站中的Azure Web应用程序中使用Pthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆