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.
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:PHPPHP.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.
- Using Windows® Explorer, browse to C:PHP and open the Php.ini file in the PHP installation directory.
- Edit and set the display_errors = On directive.
- Save the file.
- 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:inetpubusersxxxhttpdocsmysiteerror.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.
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.
GET STARTED
var google_conversion_label = «owonCMyG5nEQ0aD71QM»;
-
+1 888 500 1070 (Toll Free)
-
+1 888 500 1070 (Toll Free)
- Product
Unique Public & Private Cloud Management Portal for Data centers, Enterprise & Webhosting Companies.
Easy-to-use self-service portal allows your customers the freedom to manage their cloud with minimal handholding.
Self-service portal allows businesses to manage their resources, monitoring & vulnerability scan, by themselves.
Centralized governance and secure and holistic management of resources across multiple clouds through RBAC.
- Cloud services & AIOps
PUBLIC CLOUD
Transform Your Enterprise on AWS Cloud Platform with Cost-Effective, AIOps-Driven Managed Offerings.
GCP
Assistanz helps Enterpise, drive innovation, manage costs, governance and risks associated with their workloads on Google Cloud Platform.
CONTAINER ORCHESTRATION
Orchestrate containerized applications across multiple environments with end-to-end support from certified Kubernetes administrators.
Helps organizations increase efficiency, reduce cost and speed up time to market through pipeline automation across different cloud platforms.
PRIVATE CLOUD
Assistanz are the largest supporter of CloudStack since 2015, specializing in design & implementation of laaS for private & public clouds.
- Support Services
Our IMS Plans cover IT infrastructure planning, design, implementation, maintenance and evloution
If you are looking for staffs who could augment your webhosting business, then Assistanz is just the partner you’re looking for.
Offload your cPanel Server management & support overheads and focus only on your business.
A fully comprehensive plan to manage your Linux & Windows Plesk Servers.
Our DirectAdmin server management plan provides you with unlimited hours of server.
Enable easy migration of applications to cloud with our robust cloud server migration services.
Connect with US
Looking for more cutomized support solutions ?
Our team is ready to help you
Explore our free Configuration package, Scripts, Automations & More..
Quality Management System
- Company
Established in 2004, Assistanz has become one of the most preferred IT Service providers across diverse industry segments and a complete one-stop shop for all your IT Needs & Solutions.
Questions about our service?
Our team can answer them for your within a day..If you care for a career…
- Blog
- Product
Unique Public & Private Cloud Management Portal for Data centers, Enterprise & Webhosting Companies.
Easy-to-use self-service portal allows your customers the freedom to manage their cloud with minimal handholding.
Self-service portal allows businesses to manage their resources, monitoring & vulnerability scan, by themselves.
Centralized governance and secure and holistic management of resources across multiple clouds through RBAC.
- Cloud services & AIOps
PUBLIC CLOUD
Transform Your Enterprise on AWS Cloud Platform with Cost-Effective, AIOps-Driven Managed Offerings.
GCP
Assistanz helps Enterpise, drive innovation, manage costs, governance and risks associated with their workloads on Google Cloud Platform.
CONTAINER ORCHESTRATION
Orchestrate containerized applications across multiple environments with end-to-end support from certified Kubernetes administrators.
Helps organizations increase efficiency, reduce cost and speed up time to market through pipeline automation across different cloud platforms.
PRIVATE CLOUD
Assistanz are the largest supporter of CloudStack since 2015, specializing in design & implementation of laaS for private & public clouds.
- Support Services
Our IMS Plans cover IT infrastructure planning, design, implementation, maintenance and evloution
If you are looking for staffs who could augment your webhosting business, then Assistanz is just the partner you’re looking for.
Offload your cPanel Server management & support overheads and focus only on your business.
A fully comprehensive plan to manage your Linux & Windows Plesk Servers.
Our DirectAdmin server management plan provides you with unlimited hours of server.
Enable easy migration of applications to cloud with our robust cloud server migration services.
Connect with US
Looking for more cutomized support solutions ?
Our team is ready to help you
Explore our free Configuration package, Scripts, Automations & More..
Quality Management System
- Company
Established in 2004, Assistanz has become one of the most preferred IT Service providers across diverse industry segments and a complete one-stop shop for all your IT Needs & Solutions.
Questions about our service?
Our team can answer them for your within a day..If you care for a career…
- Blog
-
Blog, Technologies
-
Loges -
September 30, 2017
Steps to Resolve 500 Internal Server Error for PHP in IIS on Windows 2016
In this blog, we will show you the steps to resolve 500 Internal Server Error for PHP in IIS on Windows 2016.
ACCESSING PHP INFO PAGE
- To troubleshoot this issue, place a phpinfo page under your website home folder.
<?php phpinfo(); ?>
- Open the web browser and access the URL http://localhost/phpinfo.php and if you see the 500 Internal Server Error. Follow the below steps.
VERIFY THE IIS HANDLER MAPPING
- Make sure that PHP was configured correctly in IIS.
- Open IIS snap-in and click on the server name.
- Double click on Handler Mappings icon.
- You can see the list of handlers configured in that server. Double click on the PHP handler.
- Make sure that php-cgi.exe was added as executable in IIS.
VERIFYING PHP MODULES
- Open the command prompt and go-to PHP binary folder. In this demo, it is C:program filesphp 7.1 folder.
- Type the below command to view the available modules in the PHP.
php –m
- If PHP dependencies are installed correctly it will show the list of available modules in PHP or it will show the error like below.
- It looks like Visual C++ is missing on the server. Google the VC++ and install it.
- Browse the below URL and download the Microsoft Visual C++ 2015 Redistributable Update 3 RC package.
https://www.microsoft.com/en-us/download/details.aspx?id=52685
- Click on Download and select vc_redist.x86.exe and click Next.
- Once the download is complete, double-click on the vc_redist.x86.exe file. Accept the License Agreement and click on Install button.
- Once the installation is successful click on close button.
- Verify the PHP modules from the command prompt again. Now you will able to see the list of modules available in PHP.
- Browse the info page again and you will able to see the PHP configuration information.
- So, PHP requires MSVC++ as a compiler to execute the coding.
VIDEO
Thanks for reading this blog. We hope it was useful for you to learn to resolve the PHP 500 internal server error in IIS
Loges
Most Popular:
When attempting to run a PHP file on Windows server 2012 and IIS, I keep getting a 500 error. I cannot find any detailed logs or anything. However, when going to PHP Manager for IIS and click check config, I get the following error:
Detailed Error Information:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP55_via_FastCGI
Error Code 0xc0000135
Requested URL http://domain.com:80/brkld3ip.php
Physical Path drive:sitesdomain.combrkld3ip.php
Logon Method Anonymous
Logon User Anonymous
I installed PHP using Microsoft Web Platform Installer 5.0 on a fresh install of Windows Server.
I am new to IIS coming from Linux. So I am not «learned» enough in IIS to know what’s going on. I have tried updating C++ redistributable 2012 update 4 as a couple websites suggest. Anybody have any other ideas?
EDIT: Another thing I checked was memory limit. One site suggested my memory limit needed to be upped. No change.
EDIT: Question: Does Windows have to be rebooted for PHP changes to take effect?
the
4688 silver badges23 bronze badges
asked Jul 20, 2014 at 2:53
2
I got caught out by a similar message, and it turned out that I had not installed the CGI Server Role (under IIS -> Application Development).
answered Apr 6, 2015 at 8:42
2
I had the same error for PHP 7.0.3 on a 2012 R2 server with IIS 8.5.
The solution is to install: Visual C++ Redistributable for Visual Studio 2015 32bits
Everything worked properly after installing this.
Will
1,13710 silver badges25 bronze badges
answered Feb 11, 2016 at 21:52
Still had the 500 error after installing the Visual C++ Redistributable for Visual Studio 2015 32bits.
Ran procmon from microsoft sysinternals and when requesting my php web page found
w3wp.exe C:PHPphp-cgi.exe "ACCESS DENIED"
w3wp.exe is the app pool running under IIS
Giving the specific app pool user READ/EXECUTE permissions to c:php fixed the issue.
answered Feb 29, 2016 at 10:19
robrob
1391 silver badge9 bronze badges
Resolve the 500 Internal Server Error for PHP 7.4 with IIS on Windows Server for WordPress
Many of my readers will know I run a tight ship when it comes to keeping my blog infrastructure up to date and as secure as I can. This means, among other things, I keep my operating system recent and patched. The same goes for my MySQL database, PHP versions, and WordPress + plugins.
Recently I wanted to upgrade to PHP 7.4 that was just released and should be compatible with WordPress 5.3.1.
But once I switched to PHP 7.4 my site responded with the dreaded 500 Internal Server Error. Instead of going trial and error I decided to zoom in fast to the root cause to resolve the 500 Internal Server Error for PHP 7.4 with IIS on Windows Server.
Troubleshooting steps
The fasted way to figure out what issues PHP has is to open an elevated command prompt and navigate to the install path of your PHP version. For me, that would be C:Program FilesPHPphp-7.4.0-nts-Win32-vc15-x64. Note that IIS with requires the non thread safe version of PHP.
Once there run php -m
I got greeted by this warning.
PHP Warning: ‘vcruntime140.dll’ 14.0 is not compatible with this PHP build linked with 14.16 in Unknown on line 0
That ‘s clear enough. I need to upgrade my Visual C++ runtime. I have but I need a more recent version. Basically the one for Visual ++ 2105-2019. You can grab those here for both x64 and x86.
https://aka.ms/vs/16/release/VC_redist.x64.exe
https://aka.ms/vs/16/release/VC_redist.x86.exe
I tend to install both. Just in case I have an issue with x64 PHP I can try the x86 version to try and resolve it, Normally I default to x64 bit and for the past years that has worked very well.
Once I had installed those my blog sprung back to life and that was it. If you run php -m again you won’t see the warning anymore. No need to switch themes (I have a simple one that has longevity). I also do not have to empirically disable/enable plugins. I select quality, free and modern plugins that I keep up to date or replace when needed. So, for me, that was the fix. Since most troubleshooting guided don’t start here, give it a shot. The HTTP Error 500.0 – Internal Server Error is an annoying one to troubleshoot. The PHP error log might not tell you anything as it goes wrong before it can log anything and enabling more detailed error handling does not always pinpoint something precisely. It might even send you on a wild goose chase.
If you did change the feature settings for the error pages for your site to get more detailed information to “Detailed errors” don’t forget to set it back. Configure it back to the default of “Detailed error for local requests and custom error pages for remote requests” or your custom pages. You don’t want the details shown publically.
That’s it. I hope it helps someone who tries to resolve the 500 Internal Server Error for PHP 7.4 with IIS on Windows Server
Привет, сегодня будем лечить ошибку:
HTTP Error 500.0 — Internal Server Error
C:Program Files (x86)PHPphp-cgi.exe — The FastCGI process exceeded configured request timeout
Пути к php-cgi.exe могут отличаться в каждом конкретном случае. Ошибка происходит при превышении таймаута работы скрипта. По умолчанию таймаут FastCGI 90 секунд.
Окружение
Для того, чтобы у вас браузер показал эту ошибку нужны некоторые условия:
- Веб-сервер IIS 7.0
- Настроенный на веб сервере PHP через FastCGI
- Браузер открытый локально на сервере, иначе покажется просто ошибка 500. Открывать ошибки наружу — плохой тон.
- И попытка выполнить долгий php-скрипт, который отлетит по таймауту.
Зачем увеличивать таймаут
Я не знаю зачем вам увеличивать таймаут. Я бы и себе не стал этого делать, долгое выполнение скрипта — прямая дорога к его оптимизации. Но всегда есть какая-нибудь причина, которая нас заставит это сделать.
В моём случае причиной выступил спамер, накидавший в мой phpbb форум 10000 сообщений. При попытке удалить засранца, я получил 500 в бубен. В таком случае всегда можно почистить базу данных напрямую, но это не наш метод.
Забегая вперёд скажу, что проблема была не в 10000 топиках, а в разросшихся поисковых индексах. Достаточно было удалить индексы и… тогда этой статьи бы не было. Кстати, индексы в phpbb удаляются здесь: Обслуживание — База данных — Поисковые индексы.
Таймуаты-таймауты
Сначала идём в php.ini файл и выполняем настройки:
max_execution_time = 600
max_input_time = 600
memory_limit = 512M
default_socket_timeout = 600
mysql.connect_timeout = 600
Т.е. увеличиваем нужные нам таймауты до 600 секунд. Если вы используете не MySQL, то поправьте таймаут к соединению с вашим типом БД. Добавляем также памяти, т.к. в логе ошибок PHP встретилась неприятность:
[11-Feb-2018 22:43:58 Europe/Moscow] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24 bytes) in ***путь***phpbbcachedriverbase.php on line 118
Она не относится к нашей проблеме, но тоже мешает выполнить большой php-скрипт и грохнуть спамера со всеми его опусами.
Теперь перезапускаем IIS и пробуем снова выполнить проблемный php-скрипт — и ничего не получается, потому что не все таймауты мы поправили. Идём дальше.
Запускаем оснастку IIS 7.0, выбираем наш сайт и нажимаем Advanced Settings.
Находим раздел Connection Limits, в нём Connection Time-out (seconds) и тоже меняем на 600 секунд.
Теперь перезапускаем IIS и пробуем снова выполнить проблемный php-скрипт — и снова ничего не получается, потому что не все таймауты мы поправили. Идём дальше.
Ищем в интернете AdminPack для IIS 7.0, скачиваем и устанавливаем на сервер. Перезагрузка не потребуется.
https://www.microsoft.com/en-us/download/details.aspx?id=13092
После установки пака в оснастке IIS появится новая иконка FastCGI Settings.
Заходим внутрь и видим наше PHP FastCGI приложение.
Выделяем его мышкой и нажимаем справа Edit.
И наконец-то видим искомые настройки:
Меняем на:
ActivityTimeout=600
IdleTimeout=600
RequestTimeout=600
Теперь перезапускаем iis в третий раз и пробуем снова выполнить проблемный php-скрипт — отлично, скрипт работает уже дольше 90 секунд! Даже более того, он проработает 600 секунд, согласно нашим настройкам. И если вам это поможет решить свою проблему — ура!
Мне не помогло. У меня сдохла таблица поисковых индексов на третьей минуте работы скрипта. Но я хотя бы об этом узнал из нормальной информативной ошибки. После чего индексы были удалены и вот теперь скрипт удаления спамера отработал нормально и до конца без ошибок! Правда заняло это гораздо менее 90 секунд, так что таймауты можно было бы не увеличивать, если заранее знать корень зла.
P.S. MySQL таблицу можно попробовать восстановить командой:
CHECK TABLE имя_таблицы;
REPAIR TABLE имя_таблицы;
If your Internet Information Services (IIS) produces a 500 – Internal server error, your website is in serious trouble. Debugging an IIS 500 – Internal server error can take some time, so you’d better be prepared for the worst-case scenario. You don’t want to research how to deal with this error under time pressure.
Contents
- Cause of 500 – Internal server error
- Debugging an IIS 500 – Internal server error
- Resolving an IIS 500 – Internal server error
- Common 500.x substatus codes
- Author
- Recent Posts
Surender Kumar has more than twelve years of experience in server and network administration. His fields of interest are Windows Servers, Active Directory, PowerShell, web servers, networking, Linux, virtualization, and penetration testing. He loves writing for his blog.
Latest posts by Surender Kumar (see all)
- Extending LVM space in Ubuntu — Thu, Feb 2 2023
- Backup in Proxmox VE — Thu, Jan 26 2023
- Snapshots in Proxmox VE — Wed, Jan 25 2023
In my previous posts, you learned about detailed errors and failed request tracing in IIS (Internet Information Server). I recommend reading those articles first before you proceed with this one.
Cause of 500 – Internal server error
This is the most common error you will encounter with any website hosted with IIS. In most cases, a developer messed up. Thus, the fastest way is often to simply reverse the last action taken, such as restoring an earlier version of your web application. Once your system is running again, you can investigate the cause of the error on your test side in peace.
500 Internal server error
The HTTP 500 error is a server-side error. While we understand that the problem is on the server end, the error is usually ambiguous. It doesn’t exactly tell the administrator what is wrong with the server. Thus, debugging a 500 – Internal server error often takes some time.
Debugging an IIS 500 – Internal server error
Since the above error doesn’t really tell what’s actually wrong with the server, we need to enable detailed errors, as discussed in my previous post. Once detailed errors are enabled, you will see more detailed error information, including an HTTP substatus code. Sometimes even the detailed errors don’t show any useful information right away. For example, see the following screenshot:
The page cannot be displayed because an internal server error has occurred
Here I am getting: The page cannot be displayed because an internal server error has occurred. There is no HTTP status code or substatus code listed on the error page. If you get such an error even when detailed errors are enabled, right-click anywhere in the browser window and select Inspect (or press F12).
Opening developer tools in web browser to reveal server errors
This opens the developer tools in your browser window. Now, click the Console tab. The actual error thrown by the web server is displayed.
Viewing server errors using the Console tab of the web browser’s developer tools
To further understand the exact cause of 500 errors, enable Failed Request Tracing, as discussed in my previous post. Now, try to replicate the problem. If you can replicate it, open the newly generated XML log file in a web browser. The following screenshot shows the actual cause of a 500 – internal server error with a substatus code of 19 (HTTP 500.19 error):
Determining the cause of a 500 error using the Failed Request Tracing log file
Usually, substatus code 19 indicates that the configuration data is invalid. This could be due to some malformed or unidentified element in a server-level config file (ApplicationHost.config) or website-level config file (web.config). If you take a closer look at the ConfigExceptionInfo field of the log file, you will find the exact line number (6 in our case) in the web.config file that caused the exception. Now let’s take a look at the web.config file itself.
Viewing the problematic element in the web.config file
Here, you can see that the developer tried to add a mime type in the config file, but it was already defined in the server-level configuration file (i.e., ApplicationHost.config). Therefore, the Cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.mp4’ exception was returned. Furthermore, if there is some unidentified element, a syntax error, or even a typo in the web.config file, you will most likely get a similar error.
Resolving an IIS 500 – Internal server error
To resolve an IIS 500 – Internal server error, you could simply remove the line that is causing the exception. Alternatively, if you don’t want to remove this line for some reason, add the following code right above line 6 in web.config:
<remove fileExtension=".mp4" />
By doing this, you are essentially overriding the server-level element. In the end, your web.config file should look as shown below:
Overriding the server level mime element with web.config file
Now refresh the page, and the error should go away. This was just one example of resolving a 500.19 error. If you get a 500 error with a different substatus code, use the same approach to troubleshoot the problem.
Common 500.x substatus codes
The following table covers some of the most common HTTP 500 substatus codes, along with their probable causes and troubleshooting advice:
Subscribe to 4sysops newsletter!
Status Code | Probable Cause | Troubleshooting Advice |
500.11 | The application is shutting down on the web server | The application pool is shutting down. You can wait for the worker process to finish the shutdown and then try again. |
500.12 | The application is busy restarting on the web server | This is a temporary error and should go away automatically when you refresh the page. If the error persists, something is wrong with the web application itself. |
500.13 | The web server is too busy | This error indicates that the number of incoming concurrent requests exceeded the number that your IIS application can process. This could be caused when the performance settings are not right. To troubleshoot such issues, a memory dump needs to be captured and analyzed using tools such as Debug Diagnostic. |
500.15 | Direct requests for Global.asax file are not allowed | A direct request was made for the Global.asa or Global.asax file, which is not allowed by the web server |
500.19 | The configuration data is invalid | We already covered how to fix this error above |
500.21 | The module not recognized | This status code is caused by a partial installation of the IIS server, such as missing ISAPI modules. To fix this error, identify the missing IIS components and install them. |
Once you troubleshoot the problem, don’t forget to disable Failed Request Tracing and revert the detailed errors to custom errors on your web server.