Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
litespeed_wiki:php:run-without-timeouts [2019/03/24 16:45]
qtwrk
litespeed_wiki:php:run-without-timeouts [2019/06/06 18:20]
Jackson Zhang
Line 149: Line 149:
  
 **Note:** You need to turn off keepalive connections for this request. This can be done with a rewrite rule. **Note:** You need to turn off keepalive connections for this request. This can be done with a rewrite rule.
 +
 +====== Troubleshooting ======
 +===== noabort rule should be placed on the top of the .htaccess =====
 +A user tres to run a timeout.php test script. ​
 +
 +<​code>​
 +?php
 +
 +//Store the micro time so that we know
 +//when our script started to run.
 +$executionStartTime = microtime(true);​
 +
 +// displaying time
 +echo date('​h:​i:​s'​)."​\n"​ ;
 +
 +// delaying execution of the script for 2 seconds
 +sleep(320);
 +
 +// displaying time again
 +echo date('​h:​i:​s'​);​
 +
 +//At the end of your code, compare the current
 +//microtime to the microtime that we stored
 +//at the beginning of the script.
 +$executionEndTime = microtime(true);​
 +
 +//The result will be in seconds and milliseconds.
 +$seconds = $executionEndTime - $executionStartTime;​
 +
 +//Print it out
 +echo "This script took $seconds to execute.";​
 +?>
 +</​code>​
 +
 +It sets sleep time to 320 seconds, however, run https://​domain.com/​timeout.php,​ it will error out and stop at 300 seconds (5 mins), while https://​domain.com/​phpinfo.php shows "​max_exectution_time"​ is 600. LiteSpeed webserver has 300 second default timeout. However it can be overrided by noabort or noconntimeout rule. 
 +
 +A user tries to add noabort or noconntimeout rule to .htaccess, but seems the test script will still stop at 300 seconds. ​
 +
 +The .htaccess rules are:
 +
 +<​code>​
 +Oct8ne
 +                <​IfModule mod_rewrite.c>​
 +                RewriteEngine on
 +                RewriteRule ^oct8ne/​frame/​([a-zA-Z]+)$ index.php?​fc=module&​module=oct8ne&​controller=oct8neconnector&​octmethod=$1&​%{QUERY_STRING} [QSA,L]
 +                </​IfModule>​
 +                #End_Oct8ne
 +                # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
 +# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
 +# http://​www.prestashop.com - http://​www.prestashop.com/​forums
 +
 +<​IfModule mod_rewrite.c>​
 +<​IfModule mod_env.c>​
 +SetEnv HTTP_MOD_REWRITE On
 +</​IfModule>​
 +
 +RewriteEngine on
 +
 +#
 +RewriteRule . - [E=REWRITEBASE:/​]
 +RewriteRule ^api$ api/ [L]
 +
 +RewriteRule ^api/(.*)$ %{ENV:​REWRITEBASE}webservice/​dispatcher.php?​url=$1 [QSA,L]
 +
 +# Images
 +RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$1$2$3.jpg [L]
 +RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$1$2$3$4.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$1$2$3$4$5.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$4/​$1$2$3$4$5$6.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$4/​$5/​$1$2$3$4$5$6$7.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$4/​$5/​$6/​$1$2$3$4$5$6$7$8.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$4/​$5/​$6/​$7/​$1$2$3$4$5$6$7$8$9.jpg [L]
 +RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?​(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​p/​$1/​$2/​$3/​$4/​$5/​$6/​$7/​$8/​$1$2$3$4$5$6$7$8$9$10.jpg [L]
 +RewriteRule ^c/​([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​c/​$1$2$3.jpg [L]
 +RewriteRule ^c/​([a-zA-Z_-]+)(-[0-9]+)?/​.+\.jpg$ %{ENV:​REWRITEBASE}img/​c/​$1$2.jpg [L]
 +# AlphaImageLoader for IE and fancybox
 +RewriteRule ^images_ie/?​([^/​]+)\.(jpe?​g|png|gif)$ js/​jquery/​plugins/​fancybox/​images/​$1.$2 [L]
 +
 +# Dispatcher
 +RewriteCond %{REQUEST_FILENAME} -s [OR]
 +RewriteCond %{REQUEST_FILENAME} -l [OR]
 +RewriteCond %{REQUEST_FILENAME} -d
 +RewriteRule ^.*$ - [NC,L]
 +RewriteRule ^.*$ %{ENV:​REWRITEBASE}index.php [NC,L]
 +
 +AddType application/​vnd.ms-fontobject .eot
 +AddType font/ttf .ttf
 +AddType font/otf .otf
 +AddType font/woff2 .woff2
 +AddType application/​x-font-woff .woff
 +<​IfModule mod_headers.c>​
 +        <​FilesMatch "​\.(ttf|ttc|otf|eot|woff|woff2|svg)$">​
 +                Header set Access-Control-Allow-Origin "​*"​
 +        </​FilesMatch>​
 +</​IfModule>​
 +
 +#If rewrite mod isn't enabled
 +ErrorDocument 404 /​index.php?​controller=404
 +
 +# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
 +
 +# # BEGIN litespeed noconntimeout noabort
 +<​IfModule Litespeed>​
 + ​RewriteEngine On
 + ​RewriteRule .* - [E=noabort:​1]
 +</​IfModule>​
 +# # END litespeed noconntimeout noabort
 +
 +# php -- BEGIN cPanel-generated handler, do not edit
 +# Set the “ea-php70” package as the default “PHP” programming language.
 +<​IfModule mime_module>​
 +  AddHandler application/​x-httpd-ea-php70 .php .php7 .phtml
 +</​IfModule>​
 +# php -- END cPanel-generated handler, do not edit
 +
 +# BEGIN cPanel-generated php ini directives, do not edit
 +# Manual editing of this file may result in unexpected behavior.
 +# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
 +# For more information,​ read our documentation (https://​go.cpanel.net/​EA4ModifyINI)
 +<​IfModule php7_module>​
 +   ​php_flag display_errors Off
 +   ​php_value max_execution_time 600
 +   ​php_value max_input_time 600
 +   ​php_value max_input_vars 6000
 +   ​php_value memory_limit 1024M
 +   ​php_value post_max_size 1024M
 +   ​php_value session.gc_maxlifetime 1440
 +   ​php_value session.save_path "/​var/​cpanel/​php/​sessions/​ea-php73"​
 +   ​php_value upload_max_filesize 1024M
 +   ​php_flag zlib.output_compression Off
 +</​IfModule>​
 +<​IfModule lsapi_module>​
 +   ​php_flag display_errors Off
 +   ​php_value max_execution_time 600
 +   ​php_value max_input_time 600
 +   ​php_value max_input_vars 6000
 +   ​php_value memory_limit 1024M
 +   ​php_value post_max_size 1024M
 +   ​php_value session.gc_maxlifetime 1440
 +   ​php_value session.save_path "/​var/​cpanel/​php/​sessions/​ea-php73"​
 +   ​php_value upload_max_filesize 1024M
 +   ​php_flag zlib.output_compression Off
 +</​IfModule>​
 +# END cPanel-generated php ini directives, do not edit
 +</​code>​
 +
 +The noabort rule was placed almost the end of the .htaccess and it is prevented being executed by other rules.  ​
 + ​RewriteRule .* - [E=noabort:​1]
 +
 +Move the rule to the very top of all rules in .htaccess and everything works fine now.
  • Admin
  • Last modified: 2019/06/06 18:49
  • by Lisa Clarke