php-cgi.exe

PHP CGI Executor for Web Servers

Application ProcessSafeWeb Server Component
CPU Usage
1-10%
Memory
50-200 MB
Location
C:\Program Files\PHP
Publisher
The PHP Group

Quick Answer

php-cgi.exe is a legitimate PHP CGI executable. It runs PHP code on CGI/FastCGI-enabled servers and spawns worker processes to handle PHP requests.

Is it a Virus?
✔ NO - Safe
Must be in C:\Program Files\PHP\ or C:\php\
Warning
Many processes normal
Each PHP request may spawn a php-cgi.exe instance
Can I Disable?
✔ YES
Disable via web server configuration or stop the PHP CGI handler when maintenance is needed

What is php-cgi.exe?

php-cgi.exe is the PHP CGI executable used by some web servers to run PHP scripts via the CGI or FastCGI interface. When a PHP request arrives, the server may launch php-cgi.exe to interpret the PHP file and return generated HTML, JSON, or other output. It can spawn multiple instances to handle concurrent requests.

php-cgi.exe runs PHP code for each CGI/FastCGI request, isolating execution from the main server process, loading php.ini, and communicating through standard input/output with the web server to produce dynamic content.

Quick Fact: CGI/FastCGI with php-cgi.exe allows per-request isolation, improving stability for concurrent PHP processing.

Types of PHP-CGI Processes

Is php-cgi.exe Safe?

Yes, php-cgi.exe is safe when it comes from an official PHP distribution and is used by a properly configured web server.

Is php-cgi.exe a Virus or Malware?

The real php-cgi.exe is NOT a virus. Malicious files can mimic names; always verify location and signature.

How to Tell if php-cgi.exe is Legitimate or Malware

  1. File Location:: Ensure php-cgi.exe resides in C:\Program Files\PHP\ or C:\php\. Any other directory is suspicious.
  2. Digital Signature:: Right-click php-cgi.exe → Properties → Digital Signatures. Look for a valid signer such as the PHP Group.
  3. Version and Path Consistency:: Open a command prompt and run php-cgi.exe -v from the expected path; verify version matches your PHP distribution.
  4. Resource Usage:: Normal PHP-CGI usage varies by workload; unusual constant high CPU with no PHP traffic is a red flag.

Red Flags: If php-cgi.exe is located in temp folders, AppData, or System32, runs without server requests, lacks a valid signature, or shows unusual resource patterns, scan for malware and verify server configuration.

Why Is php-cgi.exe Running on My Server?

php-cgi.exe runs to interpret PHP scripts as part of CGI/FastCGI configurations. It may be invoked for each request or kept alive by the FastCGI wrapper, depending on server settings.

Reasons it's running:

Can I Disable or Remove php-cgi.exe?

Yes, you can disable php-cgi.exe. If you are not using CGI/FastCGI, you can remove or reconfigure the PHP handler. Ensure you keep PHP installed if you rely on PHP running under a different interface.

How to Stop php-cgi.exe

How to Uninstall PHP CGI / PHP

Common Problems: High CPU or Memory Usage

If php-cgi.exe is consuming excessive resources, consider the following checks and fixes tailored to CGI/FastCGI deployments.

Common Causes & Solutions

Quick Fixes:
1. Quick Fixes:
2. 1. Identify heavy PHP requests with the server's logs or monitoring tool; reproduce the issue locally
3. Restart the web server to recycle php-cgi.exe workers
4. Enable OPcache and set appropriate memory limits in php.ini
5. Review and disable unused PHP extensions via the server's PHP configuration
6. Tune FastCGI settings (max instances, idle timeout) to balance load

Frequently Asked Questions

Is php-cgi.exe a virus?

No, the legitimate php-cgi.exe from a PHP distribution is not a virus. Verify it resides in a PHP install path such as C:\Program Files\PHP\ and has a valid digital signature.

Why is php-cgi.exe using so much CPU?

High CPU typically stems from heavy PHP scripts, inefficient queries, or many concurrent requests. Use server-side monitoring (and optionally OPcache) to identify and optimize the culprit.

Where is php-cgi.exe located on Windows?

Common locations include C:\Program Files\PHP\php-cgi.exe or C:\PHP\php-cgi.exe. Confirm the path matches your PHP installation and server configuration.

Can I disable php-cgi.exe if I use PHP-FPM or mod_php?

Yes. If you switch to PHP-FPM (on Unix-like systems) or a non-CGI PHP handler, you can remove or disable the CGI-based php-cgi.exe wrapper in your server configuration.

How do I secure php-cgi.exe?

Keep PHP up to date, run only necessary extensions, run the web server with restricted permissions, and enable logging to detect unusual CGI activity.

What is the difference between PHP-CGI and PHP-FPM?

PHP-CGI runs PHP as CGI processes for each request or a small pool, while PHP-FPM uses a persistent pool of workers with advanced process management, generally providing better performance and scalability.

Related Processes