douye4051 2012-07-14 01:10
浏览 27
已采纳

使用PHP exec()的Apache文件执行模型

Newly registered user here after being a long time lurker!

I have an Apache 2.2 web server running on Windows locally (for now) as a service, with PHP 5 installed. I'm using PHP's exec() to run a command line client (.exe) hosted on the server, which authenticates the user to a database and makes pre-defined SQL queries on behalf of the user.

My question is: How does Apache run programs requested by multiple users through the (same) PHP exec() command? In this case, will Apache be using the same one instance of the client for all users who will access it, or will Apache be creating a new instance of the client for each user?

Since the client was designed for use by a single user, if Apache does reuse the same instance of a client, it will be running into a lot of concurrency issues.

I appreciate any help I can get, thanks!

  • 写回答

1条回答 默认 最新

  • douquejituan938904 2012-07-14 04:11
    关注

    PHP launches the process every time PHP calls exec(), and it keeps running for as long as it takes to finish. As such, you will end up with multiple copies of the process running at once if multiple users are simultaneously accessing scripts your web site which trigger it.

    Unless you are using some really weird sort of database, there is probably a better way to query it than launching a command-line tool. If there's an ODBC driver available for your database, for instance, you may be able to use it directly via the PHP ODBC extension.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?