dongxi4235 2014-08-12 02:49
浏览 112

Apache(php)在同时调用2个或更多php文件时崩溃

I need to load multiple files from a database and I am using php to do it.

I am using windows 7 64 bits and xampp and uniserver as servers (xampp 1.8.3-4 VC11 and uniserver XI 11.3.1). Both crashes when I load at the exact same time two php files (they can be the same file with different get variables or different files). I tried with an older version of xampp but happens the same problem.

EDIT: I noticed that it only happens using the browser palemoon (I am using the version 24.7.1 x64). Chrome, Opera and Firefox works well. I don't understand why.

To reproduce it I only need to create a html file index.html with this content:

<!doctype html>
<html>
<head>
    <link rel="stylesheet" href="a.php"/>
    <link rel="stylesheet" href="b.php"/>
</head>
</html>

Now, create two blank files, one called a.php and the other b.php (it doesn't matter what it is written in them)

Lastly open the html on a browser and do ctrl-f5 until apache crashes.

The only thing apache logs about this is

[Tue Aug 12 04:38:14.576000 2014] [mpm_winnt:notice] [pid 3880:tid 148] AH00428: Parent: child process 3368 exited with status 3221225477 -- Restarting.
[Tue Aug 12 04:38:14.686000 2014] [mpm_winnt:notice] [pid 3880:tid 148] AH00455: Apache/2.4.10 (Win32) PHP/5.4.31 configured -- resuming normal operations
[Tue Aug 12 04:38:14.686000 2014] [mpm_winnt:notice] [pid 3880:tid 148] AH00456: Apache Lounge VC10 Server built: Jul 19 2014 11:02:31
[Tue Aug 12 04:38:14.686000 2014] [core:notice] [pid 3880:tid 148] AH00094: Command line: 'C:\\UniServerZ\\core\\apache2\\bin\\httpd_z.exe -d C:/UniServerZ/core/apache2 -f C:\\UniServerZ\\core\\apache2\\conf\\httpd.conf -d C:\\UniServerZ\\core\\apache2'
[Tue Aug 12 04:38:14.688000 2014] [mpm_winnt:notice] [pid 3880:tid 148] AH00418: Parent: Created child process 5040
[Tue Aug 12 04:38:15.267000 2014] [mpm_winnt:notice] [pid 5040:tid 568] AH00354: Child: Starting 150 worker threads.

I found this bug report but the last entry is from 2004 so I am wondering if this problem is a bug and, if it is, is the same bug: https://bugs.php.net/bug.php?id=25570

EDIT: Using this C# makes the server crash sometimes

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

class MainClass
{
    public static void Main (string[] args)
    {
        IPAddress ipAddress = Array.FindAll(
            Dns.GetHostEntry("127.0.0.1").AddressList,
            a => a.AddressFamily == AddressFamily.InterNetwork)[0];
        IPEndPoint remoteEP = new IPEndPoint(ipAddress,80);

        Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );

        string request = "GET /a.php HTTP/1.1
" + 
            "Host: 127.0.0.1
" +
            "
";

        sender.Connect(remoteEP);

        sender.Send (Encoding.UTF8.GetBytes (request));
        sender.Send (Encoding.UTF8.GetBytes (request));

        byte[] buffer = new byte[4096];
        int nBytes = 0;
        try {
            while ((nBytes = sender.Receive(buffer,4096, SocketFlags.None)) > 0)
            {
                // From byte array to string
                string s = Encoding.UTF8.GetString(buffer, 0, nBytes);
                Console.WriteLine(s);
            }
        } catch (SocketException e) {
            Console.WriteLine("error {0}", e.ErrorCode);
        }

        Console.WriteLine("
Press a key...");
        Console.ReadKey();

    }
}

EDIT: I am using Connection: Close on the windows xampp server to elude the problem. My linux vps works perfectly, it only happens on the windows server.

  • 写回答

1条回答 默认 最新

  • douqing0713 2014-08-12 02:57
    关注

    I dont exactly understand your question, but I think this is what you mean. You can't use <link rel="stylesheet" /> to include a php file.

    In order to include php code, you would have to do the following:

    <!doctype html>
    <html>
        <head>
           <!-- <link rel="stylesheet" href="a.php"/>
           <link rel="stylesheet" href="b.php"/> -->
        </head>
    <?php
    
     require "a.php";
     require "b.php";
    
    ?>
    </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配