简体   繁体   English

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

[英]Apache (php) crashes when calling 2 or more php files at the same time

I need to load multiple files from a database and I am using php to do it. 我需要从数据库中加载多个文件,而我正在使用php来做到这一点。

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). 我将Windows 7 64位和xampp和uniserver用作服务器(xampp 1.8.3-4 VC11和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). 当我在完全相同的时间加载两个php文件时,两者都崩溃(它们可以是具有不同get变量的相同文件或不同文件)。 I tried with an older version of xampp but happens the same problem. 我尝试使用较旧版本的xampp,但发生相同的问题。

EDIT: I noticed that it only happens using the browser palemoon (I am using the version 24.7.1 x64). 编辑:我注意到,它仅在使用浏览器palemoon时发生(我使用的是24.7.1 x64版本)。 Chrome, Opera and Firefox works well. Chrome,Opera和Firefox运行良好。 I don't understand why. 我不明白为什么。

To reproduce it I only need to create a html file index.html with this content: 要重现它,我只需要创建一个具有以下内容的html文件index.html:

<!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) 现在,创建两个空白文件,一个空白文件称为a.php,另一个空白文件b.php(无论它们写什么都无所谓)

Lastly open the html on a browser and do ctrl-f5 until apache crashes. 最后,在浏览器上打开html并执行ctrl-f5,直到apache崩溃。

The only thing apache logs about this is apache唯一记录的是

[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 我找到了这个错误报告,但是最后一个条目是2004年发布的,所以我想知道这个问题是否是一个错误,如果是,则是相同的错误: https : //bugs.php.net/bug.php?id=25570

EDIT: Using this C# makes the server crash sometimes 编辑:使用此C#有时会使服务器崩溃

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\r\n" + 
            "Host: 127.0.0.1\r\n" +
            "\r\n";

        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("\nPress a key...");
        Console.ReadKey();

    }
}

EDIT: I am using Connection: Close on the windows xampp server to elude the problem. 编辑:我正在使用Connection: Close在Windows xampp服务器上Connection: Close以逃避该问题。 My linux vps works perfectly, it only happens on the windows server. 我的linux vps完美运行,它仅在Windows服务器上发生。

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. 您不能使用<link rel="stylesheet" />包含php文件。

In order to include php code, you would have to do the following: 为了包括php代码,您必须执行以下操作:

<!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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM