0

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>
  • You should reconsider, php-fpm is the best option in most cases. – ezra-s Apr 12 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 at 17:45
0

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.

  • 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 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.