Reputation: 41
I have a new server with CentOS 8, and I wanna have LAMP on it. In order to integrate PHP with Apache, I can remember there are two solutions: CLI and Apache module. But all howtos that I found are using php-fpm (which apparently is the CLI config with Apache).
I wanna know is there a way to config PHP as an Apache module on CentOS? If so, which package I should install using dnf?
One more thing, I can remember it was recommended to use PHP as an Apache module rather than using it as CLI. Is that still correct?
Upvotes: 1
Views: 459
Reputation: 14628
By php-cli
, you probably meant php-cgi.
php-cli is meant for running scripts from within terminal, not to be invoked from web server.
mod_php is not threadsafe if used in threaded MPM like event
.
For best performance you should try FPM, which is separate pool of workers that could be invoked via socket, regardless of actual MPM used by Apache.
Upvotes: 0
Reputation: 2673
First thing - php-cli
is meant for console operation without knowledge of HTTP request, HTTP server env variables and so on. It is used for CLI tasks like scripts run by CRON
.
What you need is to have mod_php
package installed. Then you have to enable (and configure) it within apache configuration.
According to this article the metapackage php
should already include mod_php
, so it should suffice to enable it.
The module can be enabled interactively using a2enmod
or by adding config directives manually, like:
LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so
The example is not from Centos, so YMMV.
Upvotes: 1