4

We have a site that's performing very slowly. I have a suspicion that it's php-fpm configs, but rather than play with it if it's not the issue, I want to do performance tests first.

So I cloned one of our load balancer production VMs and want to remove php-fpm but not sure how.

CentOS 7.6, httpd 2.4.38, php7.2

Stopping the php-fpm obviously does nothing but break it. Moving the file /etc/httpd/conf.d/php-fpm.conf just stops all interpretation of PHP files, so how I do get it back to mod_php?

EDIT: 1) Installed mod_php72u.x86_64 2) Added a php.conf file in /etc/httpd/conf.d/ with the following contents:

#
# The following lines prevent .user.ini files from being viewed by Web clients.
#
<Files ".user.ini">
    Require all denied
</Files>

#
# Allow php to handle Multiviews
#
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

# mod_php options
#
<IfModule  mod_php7.c>
    #
    # Cause the PHP interpreter to handle files with a .php extension.
    #
    <FilesMatch \.(php|phar)$>
        SetHandler application/x-httpd-php
    </FilesMatch>

    #
    # Uncomment the following lines to allow PHP to pretty-print .phps
    # files as PHP source code:
    #
    #<FilesMatch \.phps$>
    #    SetHandler application/x-httpd-php-source
    #</FilesMatch>

    #
    # Apache specific PHP configuration options
    # those can be override in each configured vhost
    #
    php_value session.save_handler "files"
    php_value session.save_path    "/var/lib/php/mod_php/session"
    php_value soap.wsdl_cache_dir  "/var/lib/php/mod_php/wsdlcache"

    #php_value opcache.file_cache   "/var/lib/php/mod_php/opcache"
</IfModule>
Aaron Chamberlain
  • 381
  • 1
  • 3
  • 13
  • You should reconsider, php-fpm is the best option in most cases. – Daniel Ferradal Apr 12 '19 at 11:20
  • @ezra-s Oh yeah I'm not planning on it, but I have the tedious job of figuring out why this site is slow. We moved from Rackspace to AWS and it's noticeably slower on what I thought was a 1:1 infrastructure. We still have the RS install up and certain pages are 5 times slower (tested on a server with 0 load, I.E. just me). A week in I still can't tell what it is. – Aaron Chamberlain Apr 13 '19 at 17:45

2 Answers2

6

To get back, it's quite simple:

1) Uninstall php-fpm or stop it:

sudo yum remove php72u-fpm.x86_64 php72u-fpm-httpd.noarch

OR

sudo systemctl stop php-fpm

2) Install mod_php again

sudo yum install mod_php72u.x86_64

3) Configure which listener httpd will use. The configuration file shows that prefork must be used /etc/httpd/conf.modules.d/15-php.conf contains this:

# Cannot load both php5 and php7 modules
<IfModule !mod_php5.c>
  <IfModule prefork.c>
    LoadModule php7_module modules/libphp7.so
  </IfModule>
</IfModule>

In /etc/httpd/conf.modules.d/00-mpm.conf comment out

#LoadModule mpm_event_module modules/mod_mpm_event.so

and open up LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

4) Restart Apache/httpd

sudo systemctl restart httpd

Spoiler alert: from brief testing it wasn't php-fpm so now I have to figure out what's actually causing the slowness.

Aaron Chamberlain
  • 381
  • 1
  • 3
  • 13
  • Nope, not php-fpm, and I would not be surprised if you found that it was _even slower_ with mod_php. Of course, the _point_ of using php-fpm is so that you can stop using mpm_prefork and switch to the much better performing mpm_event. – Michael Hampton Apr 11 '19 at 00:53
0

Seems even easier on Debian 10 : just had to enable and disable extant modules. Sped my apache php web page serving up by ~10x switching back to 'prefork'. I'm not sure what it is (though my current guess is that it may have something to do with a single CPU configuration); tried many an 'optimization' (+ different mpm modules). Tried it 2x, extant 'fpm' configuration definitely slowed down my system.

PHP 7.3.31-1~deb10u1, php-fpm7.3, Apache/2.4.38

dxxds
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 27 '22 at 09:33