Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:config:understanding_500 [2018/05/16 18:28]
Lisa Clarke Proofreading
litespeed_wiki:config:understanding_500 [2018/07/18 15:18]
Jackson Zhang [Faulty .htaccess]
Line 23: Line 23:
  For example, to enable the LiteMage extension in your Magento installation through SSH, you will need to run a a non-root user. However, if you run the command incorrectly as the root user, the Magento front end may return 500 instantly. The fix is to reverse file ownership and permissions back to the original user.  For example, to enable the LiteMage extension in your Magento installation through SSH, you will need to run a a non-root user. However, if you run the command incorrectly as the root user, the Magento front end may return 500 instantly. The fix is to reverse file ownership and permissions back to the original user.
  
 +===== phpinfo.php owned by root instead of user =====
 +Sometimes we need to check phpinfo page during the troubleshooting. When ssh login as root to server, go to document root and create phpinfo.php,​ the phpinfo.php file will be owned by root:root instead of user:​user. ​
 +
 +Sometimes it may return 500 error when accessing domain.com/​phpinfo.php if some restriction set there but not always. ​
 +
 +The server error may show the following:
 +[Thu Jun 07 21:​04:​36.450359 2018] [:error] [pid 3807521:tid 139749549020928] [client 77.82.94.132:​9254] SoftException in Application.cpp:​382:​ UID of script "/​home/​vivi/​public_html/​phpBB2/​info.php"​ is smaller than min_uid
 +[Thu Jun 07 21:​04:​36.450651 2018] [core:​error] [pid 3807521:tid 139749549020928] [client 77.82.94.132:​9254] End of script output before headers: info.php
 +
 +Changing the info.php to be owned by user:user will generally fix the issue. ​
 ===== Faulty .htaccess ===== ===== Faulty .htaccess =====
 There is a huge range of things ''​.htaccess''​ can do and it isn't difficult to use, however, if you do not enter the syntax correctly it can result in a Server 500 Error. ​ There is a huge range of things ''​.htaccess''​ can do and it isn't difficult to use, however, if you do not enter the syntax correctly it can result in a Server 500 Error. ​
 +
 +==== Example 1 ====
 For example, ​ For example, ​
   RewriteRule ^(.*) http://​www.example.com/​$1 [P]   RewriteRule ^(.*) http://​www.example.com/​$1 [P]
Line 30: Line 42:
   RewriteRule (.*) http://​www.example.com/​$1 [R=301,L]   RewriteRule (.*) http://​www.example.com/​$1 [R=301,L]
 And that will fix the issue. And that will fix the issue.
 +
 +==== Example 2 ====
 +<​Directory>​...</​Directory >​ can not be used in .htacess and it will cause 500 error for Apache, While LSWS will ignore the unsupported directive instead of giving 500 error.
 +
 +For example, the following should not be used in .htaccess.
 +  <​Directory /​home/​user1/​public_html/​wp-admin/>​
 +    Deny from all
 +  </​Directory>​
 +
 +instead, you can create .htaccess under /wp-admin/ and place diretive there.
 +  Deny from all
  
 To confirm whether a misconfiguration in ''​.htaccess''​ is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page. To confirm whether a misconfiguration in ''​.htaccess''​ is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page.
  
 +===== Different level of Rewrite rules misplaced to the wrong level =====
 +
 +Per virtual host rewrite rules (rewrite rules in Apache virtual host configuration) and per directory rewrite rules (rewrite rules in .htaccess) are different. ​ When placing the same rules to the wrong place, it may cause 500 error.
 +
 +For example, the following works in .htaccess: ​
 +
 +  RewriteEngine On
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteRule . /index.php [L]
 +  ​
 +Putting the same thing in Apache VirtualHost config doesn’t work at all:
 +
 +  <​VirtualHost *:80>
 +    ServerName example.com
 +    DocumentRoot /​var/​www/​example/​
 +    <​Directory /​var/​www/​example/>​
 +        Allow From All
 +    </​Directory>​
 +    RewriteEngine On
 +    RewriteCond %{REQUEST_FILENAME} !-f
 +    RewriteRule . /index.php [L]
 +  </​VirtualHost>​
 +
 +Apache doesn’t tell you why it doesn’t work. It just doesn’t work. You most likely will get an Error 500 status with a message in the logs that looks like this:
 +
 +Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
 =====  Improperly Configured php.ini ===== =====  Improperly Configured php.ini =====
 An improperly configured ''​php.ini''​ may lead to 500 error. ​ An improperly configured ''​php.ini''​ may lead to 500 error. ​
Line 63: Line 112:
 Unsupported PHP version used by the site/​theme/​plugin/​module may lead to a 500 error. Unsupported PHP version used by the site/​theme/​plugin/​module may lead to a 500 error.
  
-===== PHP Coding Timing Out =====+===== PHP Scripts Time out =====
 If your PHP script makes external network connections,​ the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error."​ To prevent these time outs and errors, make sure that PHP scripts are coded with some timeout rules. Typically, it's difficult to catch a timeout error when connecting to a database or remote resources, as they effectively freeze the script. If your PHP script makes external network connections,​ the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error."​ To prevent these time outs and errors, make sure that PHP scripts are coded with some timeout rules. Typically, it's difficult to catch a timeout error when connecting to a database or remote resources, as they effectively freeze the script.
  
Line 132: Line 181:
 ===== Hacked Site ===== ===== Hacked Site =====
 If your site is being hacked, it may trigger a 500 error. If your site is being hacked, it may trigger a 500 error.
 +
 +===== Perl script missing "​Content-Type"​ header may return 500 =====
 +
 +Run a simple "Hello World" perl script at http://​exmaple.com/​cgi-bin/​test.pl but it return 500 error.
 +
 +vi test.pl
 +<​code>​
 +  #​!/​usr/​bin/​perl
 +  print "​Hello,​ World!\n";​
 +</​code>​
 +
 +A Perl CGI script must output the header, HTML code and also must begin with a special first line. In this case, header "​Content-type"​ is missing and it is not a CGI script. Please also be aware that there is a blank line after **print "​Content-Type:​ text/​html\n\n";​**.
 +
 +the right script should be:
 +<​code>​
 +<​code>​
 +  #​!/​usr/​bin/​perl
 +  ​
 +  print "​Content-Type:​ text/​html\n\n";​
 +  ​
 +  print "​Hello,​ World!\n";​
 +</​code>​
 +You can check the example [[https://​users.cs.cf.ac.uk/​Dave.Marshall/​PERL/​node196.html|here]].
  • Admin
  • Last modified: 2019/12/10 19:33
  • by Lisa Clarke