耗时的 PHP 脚本以及解决问题的方法?

use*_*614 3 php

我有一个 PHP 注册表单,从用户单击提交按钮到它会强制服务器抛出以下错误非常耗时:

Request Timeout
This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.
Run Code Online (Sandbox Code Playgroud)

我一直在谷歌上搜索解决这个问题的方法,似乎有几种方法可以解决这个问题。但是,我想知道这样做的最佳方法是什么。

我将从用户单击提交按钮时开始解释注册表中的步骤:

step 1- it will checks the mysql database for duplicated data.
step 2- it will create 2 mysql tables with their columns
step 3- it will enter the data passed on by the user into the mysql table.
step 4- it will create a subdomain on my server.
step 5- it will move some files from one folder on my server into the newly created subdomain. there are alot of files but i don't think this should take that long? I need some advise on this please and what is the best way of doing this?
step 6- it will send a confirmation email to the user.
Run Code Online (Sandbox Code Playgroud)

我可以发布我的代码,但它非常大,所以我认为它可能会让任何人阅读这个问题。

在我的 PHP 注册页面的顶部,我有这行代码,但这没有影响:

set_time_limit(0);
Run Code Online (Sandbox Code Playgroud)

您认为最好使用以下代码吗?

ini_set('max_execution_time', 300);
Run Code Online (Sandbox Code Playgroud)

任何解决此问题的建议将不胜感激。

谢谢

Sim*_*ast 7

此特定错误消息由 LiteSpeed Web 服务器(Apache 的更快替代品)生成。它有一个特殊功能,可以取消长时间运行的脚本。要禁用此功能,您需要将以下内容放入.htaccess站点根目录的文件中。

RewriteEngine On
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]
Run Code Online (Sandbox Code Playgroud)