Switching from MPM Worker to Event with PHP-FPM

7,221

Found that I needed to make the final lines of my php.conf conditional.

<IfModule mpm_prefork_module>
#
# 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/session"
</IfModule>
Share:
7,221

Related videos on Youtube

Ryan Prentiss
Author by

Ryan Prentiss

Updated on September 18, 2022

Comments

  • Ryan Prentiss
    Ryan Prentiss almost 2 years

    CentOS 7, Apache 2.4, FPM/FastCGI, MariaDB

    My 512M VPS is eating up memory with one development WordPress site, so I'm hoping this will lead me down a path of better tuning; if not, please inform.

    I am attempting to switch from MPM Worker to MPM Event but am receiving the following error upon Apache restart:

    AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:
    Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
    

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

    # Select the MPM module which should be used by uncommenting exactly
    # one of the following LoadModule lines:
    
    # prefork MPM: Implements a non-threaded, pre-forking web server
    # See: http://httpd.apache.org/docs/2.4/mod/prefork.html
    #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    
    # worker MPM: Multi-Processing Module implementing a hybrid
    # multi-threaded multi-process web server
    # See: http://httpd.apache.org/docs/2.4/mod/worker.html
    #
    #LoadModule mpm_worker_module modules/mod_mpm_worker.so
    
    # event MPM: A variant of the worker MPM with the goal of consuming
    # threads only for connections with active processing
    # See: http://httpd.apache.org/docs/2.4/mod/event.html
    #
    LoadModule mpm_event_module modules/mod_mpm_event.so
    

    vhost:

    <VirtualHost *:80>
    
        ServerName localhost
    
        ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php-fpm/php-fpm.sock|fcgi://127.0.0.1:9000/var/www/html
    
        DocumentRoot /var/www/html
        <Directory /var/www/html>
            Options All -Indexes
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog /var/log/httpd/localhost_error.log
        CustomLog /var/log/httpd/localhost_access.log combined
    
    </VirtualHost>
    

    /etc/httpd/conf.d/php.conf

    #
    # Cause the PHP interpreter to handle files with a .php extension.
    #
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    
    #
    # 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
    
    #
    # 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/session"
    
  • mustafa
    mustafa almost 8 years
    what if you really need these values? There must be another solution to set these variables
  • Nemo
    Nemo over 5 years
    The usual recommendation is to move them to php.ini, I believe.