Php com internal error

How to Fix “500 Internal Server Error” While Running PHP

Many website owners will have come across the “500 Internal Server Error ” at some point in time. While this isn’t a very archaic error message, the more significant problem is that it may arise from many potential problems.

Thankfully, where PHP is concerned, the error is very specific – an inability to connect a request to the PHP script in question. For example, if a website visitor attempts to view a page and the connection times out, this error message will be displayed.

Resolving “500 Internal Server Error” While Running PHP

Although the root issue is known, what exactly is causing the connection to timeout can vary. Here are some of the more common methods to resolve this problem.

1. Reload or Refresh the Page

On occasion, the timeout may occur sporadically. Attempt to refresh the page a few times – if the web page can load at least once, an overloaded server likely causes the error.

Websites require resources to serve content to visitors. If your server lacks the resources to process the current volume of web traffic, you may see this error cropping up. To verify this, launch your SPanel dashboard and use the “Server Status” link to check resource usage trends.

How to Fix “500 Internal Server Error” While Running PHP

If your server is consuming many resources, provisioning for more will likely resolve your 500 Internal Server Error.

2. Check File Permissions

Another possibility is that the incorrect permissions have been set on the PHP file, causing the error. Verifying this will require you to connect to your server terminal (See “ Connect to my server with SSH ) and check log files.

Читайте также:  Php unzip file get contents

Your log files will generally be located in “/usr/local/apache/logs/error_log”

If you note messages on “SoftException in Application,” the error message is likely caused by incorrect file permission settings. To resolve this, change the permissions for the related PHP file using the File Manager tool in SPanel.

3. Check .htaccess Code

In some cases, the “500 Internal Server Error” may be caused by specific instructions set in your .htaccess file. This file provides high-level web server configurations. Both you and some web applications may amend the file, potentially causing errors.

It is advisable to move all PHP-specific instructions out of the .htaccess file and into php.ini. The php.ini file is a custom configuration file that you can build for individual applications requiring PHP to run.

Источник

PHP 500 internal server error in IIS – Causes and Fixes

500 internal server error clearly indicates that something went wrong during the display of PHP page.

By default, web servers like IIS return only generic error messages in websites. Often, this causes the masking of real reason for IIS PHP errors such as 500 internal server error.

That’s why, we frequently get request from Windows server owners to find out the reason for PHP website errors and fix them as part of our Server Management Services.

Today, we’ll take a look on how Bobcares’ Engineers track the real reason and fix php 500 internal server error in IIS.

What causes PHP 500 internal server error in IIS

Basically, 500 Internal Server Error is IIS web server’s way of saying, “Something has gone wrong when I tried to display the page. Not sure what.

Now, its time to see the exact reasons for the 500 errors.

1. Permissions Error

From our experience in managing servers, our Windows Experts often see PHP 500 internal server errors due to wrong permissions and ownership on website files. In Windows servers, every file and every folder has its own set of permissions. Again, some permissions are inherited from the parent folders too. And, when the PHP binary do not have enough permissions to execute the scripts, it can result in 500 internal server error.

Similarly, ownership of the files also create problems. In Windows, specific users like IIS User, IIS WP User, etc. should have access on the website folders and files. For example, the IUSR account should have modify permissions on php scripts. And, when there are permission problems, website shows PHP errors.

Читайте также:  From html to зва

2. Bad PHP Settings

Yet another reason for PHP internal server error is bad PHP settings. The PHP settings are specified in the configuration file at C:\PHP\PHP.ini. PHP binary take the values from this file while executing scripts.

A classic example will be PHP timeout settings. When the website PHP scripts has to fetch results from external resources, PHP timeout values often cause trouble. Most system administrators set timeout values in PHP to avoid abuse of the server resources. And, if the PHP script executes for a time longer than the threshold limits, it eventually results in 500 error.

3. PHP module errors

A very few 500 errors happen when the PHP module on the server as such becomes corrupt too. As a result, it results in processing failure of PHP scripts.

Luckily, when the website reports the 500 error due to module failures, IIS often show a more specific error messages like:

500.0 Module or ISAPI error occurred. 500.21 Module not recognized.

How we fixed PHP 500 internal server error in IIS

Fixing PHP 500 internal server error in IIS need a series of steps. Let’s now see how our Dedicated Engineers fixed it for one of our customers and made PHP scripts running.

The customer reported 500 internal server error on WordPress website running in IIS.

1. Turning On Display errors

While the error correctly suggested that PHP had caused 500 error code, it did not provide application-specific information about what caused the error. Therefore, the the first step of investigation was to turn ON display errors option. For this, our Dedicated Engineers followed the steps below.

  1. Using Windows® Explorer, browse to C:\PHP and open the Php.ini file in the PHP installation directory.
  2. Edit and set the display_errors = On directive.
  3. Save the file.
  4. Reset IIS using the command iisreset.exe

After turning on the errors, we reloaded the PHP and it showed a PHP parse error:

Parse error: parse error in C:\inetpub\users\xxx\httpdocs\mysite\error.php on line 3 >>

Often browser settings only show friendly error messages. In such cases, we recommend customer to turn it Off. For example, in Internet Explorer Go to Tools, Internet Options, Advanced tab, and then clear the Show friendly HTTP error messages check box.

Читайте также:  Меняем размер шрифта при помощи CSS

Thus, it was a coding error on the PHP script. We suggested script modifications to customer and that fixed the error.

2. Running PHP script locally

Yet another way to find the exact error is to run the problem php script within the server. For this, our Support Engineers connect to the server via rdesktop and execute php script using the php.exe binary. It would show the DLL’s that are having conflicts and causing the 500 error. We fix these conflicts and make the script working again.

3. Correcting PHP settings

In some cases, we need to correct the PHP settings to get the problem solved. Recently, when a customer reported problems with his website, we had to set the php directive open_basedir correctly to solve 500 Internal Server Error.

Similarly, when PHP cgi scripts show up some warning, IIS7 still displays an HTTP 500 error message. Although the best method is to fix the PHP scripts, often changing the default error handling for FastCGI in IIS7 to “IgnoreAndReturn200” also work as a temporary fix. The exact settings will look as shown.

4. Fixing PHP binary

In some rare cases, the fix may involve complete rebuilding of PHP binary on the server. This happens mainly when the PHP program on the server becomes corrupt. However, in such cases our Dedicated Engineers always check the dependency of the package and do the reinstall. For control panel specific servers, we set the appropriate binary on the server.

[Broken PHP scripts causing big problems? Our IIS experts have the fix for you.]

Conclusion

In a nutshell, PHP 500 internal server error in IIS happens mainly due to reasons like buggy PHP scripts, wrong server settings and many more. Today, we saw the top reasons for the error and how our Support Engineers fix it for customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

Источник

Оцените статью