Run PHP on NGINX

Sergey A. Osokin osa at freebsd.org.ru
Tue Oct 17 22:36:26 UTC 2023


Hi Jeff,

hope you're doing well.

On Tue, Oct 17, 2023 at 10:50:38AM -0500, Jeff wrote:
> Can PHP code be run using NGINX?
> I am new to web server stuff, so just investigating.

Short answer is no, NGINX by itself can't execute a PHP code.
But here's the important notes here:
1. NGINX has a fastcgi module, [1], that modules allows passing
   requests to a FastCGI server;
2. PHP distribution contains PHP FastCGI Process Manager, [2]
   is a primary PHP FastCGI implementation.

There many resources in the internet that describes how to
integrate NGINX with a FastCGI server, so I'd recommend to
start a journey from the nginx.org, [3].

Also, you may want to take a look on NGINX Unit, [4],
a lightweight and versatile application runtime hat provides
the essential components for your web application as a single
open-source server.

Hope that helps.


References
----------
1. https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
2. https://www.php.net/manual/en/install.fpm.php
3. https://nginx.org/en/docs/beginners_guide.html#fastcgi
4. https://unit.nginx.org/configuration/#configuration-php

-- 
Sergey A. Osokin


More information about the nginx mailing list