{"id":5807,"date":"2019-12-12T13:32:04","date_gmt":"2019-12-12T18:32:04","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5807"},"modified":"2019-12-12T13:32:04","modified_gmt":"2019-12-12T18:32:04","slug":"apache-switching-to-php-fpm","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5807","title":{"rendered":"Apache &#8212; Switching to PHP-FPM"},"content":{"rendered":"<p>A few system updates ago, PHP fell over completely because of some multi-processing module. The <a href=\"https:\/\/www.rushworth.us\/lisa\/?p=3004\" target=\"_blank\" rel=\"noopener noreferrer\"><em>quick<\/em> fix was to change the multi-processing module<\/a> and avoid having to figure out what changed and how to use php-fpm. Part of moving my VM&#8217;s to the new server, though, is cleaning up anything I&#8217;ve patched together as a quick fix. And, supposedly, php-fpm is a lot faster than the old-school Apache handler. Switching was a lot less involved than I had expected.<\/p>\n<p><em>Install php-fpm:<\/em><\/p>\n<pre>dnf install php-fpm<\/pre>\n<p><em>Edit 00-mpm.conf<br \/>\n<\/em><\/p>\n<p>My quick fix was to switch to a non-default multi-processing module. That change is reverted to re-enable the &#8216;event&#8217; module<\/p>\n<pre>vim \/etc\/httpd\/conf.modules.d\/00-mpm.conf<\/pre>\n<p><em>Configure Apache PHP Module<\/em><\/p>\n<p>Verify the socket name used in \/etc\/php-fpm.d\/ &#8212; Fedora is configured from \/etc\/php-fpm.d\/www.conf with a socket at \/var\/run\/php-fpm\/www.sock<\/p>\n<pre>cp \/etc\/httpd\/conf.modules.d\/15-php.conf \/etc\/httpd\/conf.modules.d\/15-php.conf.orig\r\nvi \/etc\/httpd\/conf.modules.d\/15-php.conf\r\n\r\n# Handle files with .php extension using PHP interpreter\r\n\r\n# Proxy declaration\r\n&lt;Proxy \"unix:\/var\/run\/php-fpm\/www.sock|fcgi:\/\/php-fpm\"&gt;\r\n    \tProxySet disablereuse=off\r\n&lt;\/Proxy&gt;\r\n\r\n# Redirect to the proxy\r\n&lt;FilesMatch \\.php$&gt;\r\n\tSetHandler proxy:fcgi:\/\/php-fpm\r\n&lt;\/FilesMatch&gt;\r\n\r\n#\r\n# Allow php to handle Multiviews\r\n#\r\nAddType text\/html .php\r\n\r\n#\r\n# Add index.php to the list of files that will be served as directory\r\n# indexes.\r\n#\r\nDirectoryIndex index.php\r\n<\/pre>\n<p><em>Enable php-fpm to auto-start, start php-fpm, and restart Apache<\/em><\/p>\n<pre>systemctl enable php-fpm\r\nsystemctl start php-fpm\r\nsystemctl restart httpd<\/pre>\n<p>Voila &#8212; phpinfo() confirms that I am using FPM\/FastCGI<\/p>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=5808\" rel=\"attachment wp-att-5808\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5808\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/PHP-FPM.png\" alt=\"\" width=\"451\" height=\"92\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/PHP-FPM.png 451w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/PHP-FPM-300x61.png 300w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/a><\/p>\n<p>We&#8217;ll see if this actually does anything to improve performance!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few system updates ago, PHP fell over completely because of some multi-processing module. The quick fix was to change the multi-processing module and avoid having to figure out what changed and how to use php-fpm. Part of moving my VM&#8217;s to the new server, though, is cleaning up anything I&#8217;ve patched together as a &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[31,35,863],"class_list":["post-5807","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-apache","tag-php","tag-php-fpm"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5807"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5807\/revisions"}],"predecessor-version":[{"id":5809,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5807\/revisions\/5809"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}