# CGI, FastCGI and PHP-FPM - Some basic questions

**URL:** <https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945>\
**Category:** Help! (Home for newbies)\
**Created:** [February 14, 2024, 1:20pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945 "2024-02-14T13:20:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 14, 2024, 1:20pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/1 "2024-02-14T13:20:21Z")

</div>

| SYSTEM INFORMATION | |
| --- | --- |
| OS type and version | REQUIRED |
| Virtualmin version | REQUIRED |

Hi

I have some newbie question I was hoping to get answered.

### Background

- CGI
  - the slowest php mode to run in
  - allows cgi apps to run in cgi-bin

- FastCGI
  - a much quicker implementation of CGI with permanent child process
  - allows cgi apps to be run in cgi-bin

- PHP-FPM
  - Uses the FastCGI for processing PHP requests
  - Is only for PHP

### The questions

- Is running CGI apps now considered an old way of doing things?
- Can you confirm that if I run PHP-FPM there is no way to run CGI apps?
- I can remove the PHP CGI module as this is not needed for PHP-FPM in any way?

Thanks

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 14, 2024, 6:13pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/2 "2024-02-14T18:13:02Z")

</div>

> [@shoulders](#):
>
> Is running CGI apps now considered an old way of doing things?

Generally, yes. For large applications, having them load all their dependencies on every run is wildly inefficient. For tiny little apps that don’t load a bunch of extra junk, it may be fine. e.g. if you just need to serve out one tiny API endpoint and you can write a Perl/Python/Ruby/PHP script that runs in a few milliseconds, then it may make sense to use CGI (but an app server probably isn’t notably worse than CGI in those cases, either…it’d be about balancing CPU vs. memory usage).

> [@shoulders](#):
>
> FastCGI
> 
> - allows cgi apps to be run in cgi-bin

No. FastCGI can not run CGI scripts. It requires applications built to communicate via the FastCGI protocol, which is not the CGI protocol. A CGI script is not a FastCGI script without a wrapper. We provide a wrapper (fcgiwrap), so you can run CGI applications on systems that don’t have suexec available, but it does not mean FastCGI is running CGI scripts. fcgiwrap runs CGI scripts and communicates with the web server via the FastCGI protocol. It is the application server in this context.

> [@shoulders](#):
>
> Can you confirm that if I run PHP-FPM there is no way to run CGI apps?

No. I deny that. What gave you that idea?

> [@shoulders](#):
>
> I can remove the PHP CGI module as this is not needed for PHP-FPM in any way?

Where do you see a PHP CGI module?

---

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 14, 2024, 6:43pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/3 "2024-02-14T18:43:18Z")

</div>

> [@Joe](#):
>
> No. I deny that. What gave you that idea?

Just learning about CGI 😄 and didnt really know.

> [@Joe](#):
>
> Where do you see a PHP CGI module?

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/1/1c33acaf286a3cd2958d7d9919000bea2ca882eb.png)

`apt-get install php8.1-cgi`

Sorry for all the arrows, this is my dev server and I have been messing about.

I think I should of said php extensions. 😄

And thanks for the long response. I will add this to my notes.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 14, 2024, 6:46pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/4 "2024-02-14T18:46:22Z")

</div>

We didn’t install php-cgi. That’s your business, not mine. (Though it might be a dependency of one of the other PHP packages we install…I don’t think so, though. I can’t think of any reason any of the other PHP packages would depend on php-cgi.)

---

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 14, 2024, 6:48pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/5 "2024-02-14T18:48:02Z")

</div>

I am sure I installed it 😄 I will also be uninstalling it.

It will of been installed when i used the install script from the mutiplephp documentation.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 14, 2024, 6:48pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/6 "2024-02-14T18:48:06Z")

</div>

Actually, it probably is a dependency of one of the other PHP packages, as we’ve never installed it, and we’ve historically had the ability to run PHP apps as CGI, so I guess it must have always been there.

---

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 14, 2024, 6:50pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/7 "2024-02-14T18:50:12Z")

</div>

is it not needed for this

![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/d/d5bb932c06756dfafee40586d91746272cf33c38.png)

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 14, 2024, 6:54pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/8 "2024-02-14T18:54:07Z")

</div>

Yeah, but you almost certainly don’t need that. I only ever use FPM. Sometimes I like to have CGI for debugging other execution modes, but it’s not how you should ever run a large PHP application.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 14, 2024, 6:54pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/9 "2024-02-14T18:54:49Z")

</div>

I mean, Virtualmin detects available execution modes when the config check runs. So, it won’t offer that option if you don’t have `php-cgi` and that’s a harmless thing.

---

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 14, 2024, 6:56pm UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/10 "2024-02-14T18:56:07Z")

</div>

Perfect. I will only ever use PHP-FPM, but is good to know what these things do, just in-case.

You have a good one.

---

<div class="post-metadata">

**Author:** ![verne](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/v/dbc845/32.png) [@verne](https://forum.virtualmin.com/u/verne)\
**Post date:** [February 15, 2024, 2:23am UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/11 "2024-02-15T02:23:14Z")

</div>

one of the things I really love about the php-fpm framework is you can control the max child processes - so a website becoming very busy will NOT spawn hundreds of child processes — perhaps my old system with FastCGI was not configured properly and that was why I did have 100s that then triggered OOM issues. We specifically changed over to php-fpm to have better control over excessive processes that used to lead to OOM issues.

---

<div class="post-metadata">

**Author:** ![shoulders](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/shoulders/32/10086_2.png) [@shoulders](https://forum.virtualmin.com/u/shoulders)\
**Post date:** [February 16, 2024, 11:12am UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/12 "2024-02-16T11:12:52Z")

</div>

A bit of self promotion but people might find this useful. 😄

> **[What is CGI, FastCGI and PHP-FPM | QuantumWarp](https://quantumwarp.com/kb/articles/34-web-server/1020-what-is-cgi-fastcgi-and-php-fpm)**
>
> I have struggled for years to understand what the point of the cgi-bin folder was for which then lead me to research into the whole area and what was the pint of this technology. What is CGI? CGI stan...

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [February 17, 2024, 12:01am UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/13 "2024-02-17T00:01:17Z")

</div>

Promoting docs you write is always great!

But, this is a bit misleading: “Virtualmin only supports CGI apps out of the box. You can manually add FastcGI support.”

Virtualmin supports, with full UI support, PHP apps via _many_ execution modes, including FastCGI, and multiple versions of PHP (when installed). Virtualmin also supports setting up proxy rules to any other kind of application server (many app servers do not use FastCGI, they just use HTTP, and that is the most common way to run most apps other than PHP at this point in history). FastCGI is on the way out, too.

We brought proxy paths support from Pro into GPL just recently to ease that use case. And Virtualmin Pro is about to get app server and container-based app support (where it has some awareness of the app server or docker/podman and configures the proxy rules automatically).

So, nearly any way you want to run apps in Virtualmin is very easy to do.

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [February 25, 2024, 12:02am UTC](https://forum.virtualmin.com/t/cgi-fastcgi-and-php-fpm-some-basic-questions/124945/14 "2024-02-25T00:02:06Z")

</div>

Closed on February 25, 2024, 12:02am UTC

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.
