There was a problem loading the comments.

How to fix an "500 Internal Server Error"

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Issue: 500 Internal Server Error

We have seen this error come up when clients migrate scripts to our server. Client attempts to install a PHP script (such as Drupal, Magento, Moodle, WordPress, Concrete5 etc) from sources or a previous installation of LAMP with mod_php. Upon testing the installation on IndicHosts server, an error  '500 Internal Server Error" is observed on the web browser.

 

Common sources of the issue are:

  1. Directory and File Permissions
  2. Directory and File Ownership
  3. Directives in .htaccess, such as php_value or php_flag

 

Reason & Background: As our server runs Apache with suPHP and does not use mod_php, PHP scripts are executed as 'username' instead of 'apache' or 'nobody'. Hence, all your script files and subdirectories need to be owned by the username. In addition, most of the script's documentation is focused towards basic LAMP (Linux, Apache, MySQL, PHP) with mod_php deployments. The script's documentation recommends that certain directories and files should be set to world writable (i.e. 777 or 666.). Often, PHP files, as part of a source archive, are distributed with executable permissions of 777 or 775. 

On IndicHosts servers, you should NOT have any world writable files or directories (with permission levels such as 0777, 0666, 0770, 0660, etc.). Our PHP script files (.php) should NOT be executable (with permission levels such as 0755) even if the official script documentation recommends it. This is a mandatory security requirement for PHP scripts on IndicHosts' servers.  

Hence, to correct the 500 Internal Server Error on the IndicHosts.net server, you need to do the following:

  1. All directories and subdirectories should be set to the permission level of 0755. You can correct this using FTP or by running this command in cPanel >> Terminal 

    chmod 755 directory


  2. All files in the directory and subdirectories should be set to the permission level of 0644. You can correct this using FTP or by running this command in cPanel >> Terminal 

     chmod 644 filename.php

  3. Check and remove any php_value or php_flag directives in your .htaccess file. (by removing the line or commenting it out with # prefix)

  4. Files and directories should be owned by the user to whom they belong. If the username is ‘robert’, the files should be owned and grouped as robert:robert . You can fix this by running this command in cPanel >> Terminal >> (If you don't have terminal enabled, raise a ticket and ask us to enable terminal on your domain)

    chown username:username directory
    chown username:username filename.php 

  5. An incorrect version of PHP gives "HTTP Error 500" on Google Chrome.  At times, the PHP version enabled on the domain does not meet the requirements of the script. You can use the PHP Selector or MultiPHP Manager in cPanel to change the version of PHP. We provide PHP versions 4.4 up to 8.1 for clients to choose from for their domain.

  6. ModSecurity block gives "HTTP Error 500" in Google Chrome. Please navigate to cPanel >> ModSecurity and disable ModSecurity on the domain. If the error goes away, raise a ticket with Technical Support, asking them for the ModSecurity rule that caused the exception, then contact the script developer and ask them to fix their script.

  7. Check the script documentation and ensure that the PHP environment meets the minimum requirements of the script (PHP extensions, options, and variables are enabled). To learn how to set up a PHP environment at IndicHosts on a per-domain or per-directory basis, read our PHP Setup How-To article. (Note: If you find at any point that the script requirements conflict with our Setup Article here, please contact us for clarification on how to proceed.)

 

Once you have rectified the above, refresh the script URL. If the error persists, please raise a ticket with the script details.

 

Tip: the error_log file in the script directory shows the exact PHP error behind the 500 internal server error


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net