Httpd – Centos 7 apache php-fpm seems to be not working

centos7httpdphp-fpm

Installed and related packages on the server:

php php-cli php-common php-opcache php-mcrypt php-gd php-curl php-fpm php-dom php-intl php-pecl-mongodb php-mbstring php-xml php-pear php-devel php-pecl-zip

Centos 7
Apache/httpd

Backstory:

We are moving to a new server from the old one, cuz now we finally got some time to reconfigure everything. On the old server everything was working but there was some missing features which could upgrade the performance. One of the is the php-fpm. Now the new server config is almost complete, only the connection with the auto deployment tool and the php-fpm is missing.
So I insalled the php-fpm using these tutorials:

https://www.webhostinghero.com/centos-apache-php-fpm/

https://www.mynotepaper.com/install-latest-php-php-fpm-on-centos-7/

https://www.stephenrlang.com/2018/02/centos-7-apache-2-4-with-php-fpm/

These are the top 3 results for the topic in google, and I'm kinda tired of this whole thing, because I'm worked on the entire configuration for 2 months, and I would really like to finish it now. The problem is that none of these above are working.

What is working?

Well httpd works perfectly. php-fpm has a service too and it's seems to be listening on the port nr 9000. So first issue is that I'm not entirely sure how should I find out if it's working or not.
As I said services are okay both httpd and php-fpm. Also added to auto-start

How I try to find out if it's working or not?

well there is the phpinfo – which is the mostly suggested, but my problem with that is that I dont want to put out the config for the public. We have break in attempts – unsuccessful – already on the server so it's better to keep it secured. Second option is php -i | grep "Server API"
should return with this – considering the tutorials: "FPM/fastCGI" and it returns with "Command Line Interface"

I think it might means that it's not working. Is that true?

What did I do so far?

in the /etc/php.ini I have this line as it was suggested in the tutorial: cgi.fix_pathinfo=0

Then here /etc/php-fpm.d/www.conf

user = apache
group = apache
listen.owner = apache
listen.group = apache
listen = /var/run/php-fpm/default.sock

Then here /etc/httpd/conf.modules.d/00-mpm.conf

instead of this: LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
I have this:
LoadModule mpm_event_module modules/mod_mpm_event.so

Then here /etc/httpd/conf.d/php.conf

# Proxy declaration
<Proxy "unix:/var/run/php-fpm/default.sock|fcgi://php-fpm">
    # we must declare a parameter in here (doesn't matter which) or it'll not register the proxy ahead of time
        ProxySet disablereuse=off
</Proxy>

# Redirect to the proxy
<FilesMatch \.php$>
    SetHandler proxy:fcgi://php-fpm
</FilesMatch>

plus some default stuffs. These are all from the descriptions I linked above

After the configuration the services were reloaded each times, and I get the same result. So I have no idea what is missing to make this working – mostly because first time that I'm using php-fpm with apache.

The sites are still working, but this fpm thingy isn't.

Any ideas?

Best Answer

"Any ideas?"

Perhaps something to do with needed a2enmod, a2enconf, and a2dismod commands? When I switched to php7.3-fpm on apache 2.4, I had to do the following (this was on debian 10 and ubuntu 18.04):

sudo systemctl stop apache2
sudo apt-get install php7.3-fpm  
a2enmod proxy_fcgi setenvif
a2enconf php7.3-fpm  # this may depend on your PHP vendor
a2dismod php7.3      # This disables mod_php.
a2dismod mpm_prefork # This disables the prefork MPM. Only one MPM can run at a time.
a2enmod mpm_event    # Enable event MPM. You could also enable mpm_worker.
sudo systemctl restart apache2

Exec sudo apachectl -M and look for these modules:

 http2_module (shared)
 mpm_event_module (shared)
 proxy_module (shared)
 proxy_fcgi_module (shared)