If you have enabled CGI/FastCGI using the Windows Features Experience, and even then, if you notice no CGI icon in IIS Manager, this post will help you fix the problem. You can also identify the issue when you check with the PHP manager and notice a message saying – FastCGI feature must be enabled in order to register PHP.
What is CGI/FastCGI in IIS?
Web technologies like CGI (Common Gateway Interface) allow web servers (HTTP servers) to connect to external applications like PHP. As a result of CGI, web servers can generate and process dynamic content.
Why can’t I enable CGI/FastCGI in IIS under Windows 11/10?
Follow these suggestions to restore CGI/FastCGI in IIS under Windows. These solutions are known to work as suggested by forum users.
- Run SFC & DISM, Then Reinstall
- Install with PowerShell
You will need an admin user account to execute the suggested steps.
FastCGI feature must be enabled in order to register PHP
1] Run SFC & DISM, Then Reinstall
One of the users reported that running SFC and DISM tools can help fix the problem. Once you run those tools, you must uninstall CGI and reinstall it. It will bring back the CGI and FastCGI Module in the IIS manager.
- Open Command Prompt or Windows terminal with admin permission
- Type the following commands and execute them one by one. Ensure you wait for them to complete before running the other one.
sfc /scannow DISM /Online /Cleanup-Image /RestoreHealth
- Your PC may restart once the tools complete the execution. If it doesn’t, we recommend that you manually restart the PC.
- Next, go to Windows Features, uninstall the CGI module, and reinstall it.
- Check with the IIS manager if you can see the module.
2] Install with PowerShell
Another way to resolve the issue is to install CGI and FastCGI in the Clean Boot state. This state ensures any 3rd party apps that could be stalling the proper installation. Run the following script in an elevated PowerShell window.
$features = @( "Web-WebServer", "Web-Static-Content", "Web-Http-Errors", "Web-Http-Redirect", "Web-Stat-Compression", "Web-Filtering", "Web-Asp-Net45", "Web-Net-Ext45", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Mgmt-Console", "Web-Mgmt-Tools", "NET-Framework-45-ASPNET", "Web-Mgmt-Service", "Web-Windows-Auth", "Web-CGI", "Web-Dyn-Compression", "Web-Scripting-Tools", "Web-Dyn-Compression" ) # Add Windows Features add-WindowsFeature $features -Verbose
This script will be handy if the installation fails and the DISM doesn’t help.
It is annoying when you enable a feature, it is shown as enabled, but it is not what you expected. It is one of those situations. We hope the post was easy to follow and you were able to resolve the problem where you could not enable CGI/FastCGI in IIS under Windows 11/10.
How do I know if FastCGI is enabled?
You can create a PHP file and execute the code
<?php phpinfo(); ?>. Once you access the page on your site, check the output of phpinfo and look for _SERVER[“REQUEST_URI”]. If this variable is missing, then CGI is used; else, ISAPI or FastCGI is used. If the _SERVER[“REQUEST_URI”] is empty, then CGI or FastCGI is not enabled.
What is the difference between CGI and FastCGI?
With FastCGI, external applications can interface with Web servers more efficiently than with the Common Gateway Interface (CGI), which IIS has supported since its inception. ISAPI extensions or CGI programs run PHP traditionally on IIS. A CGI program outputs dynamic information when a Web server launches it. Every CGI request is executed in a separate process that starts at the beginning and ends at the end.