{"id":3154,"date":"2018-09-06T13:08:13","date_gmt":"2018-09-06T17:08:13","guid":{"rendered":"https:\/\/www.moorezilla.com\/blog\/?p=3154"},"modified":"2025-01-08T09:17:28","modified_gmt":"2025-01-08T14:17:28","slug":"fixing-ubuntu-18-04-and-moving-to-php-fpm","status":"publish","type":"post","link":"https:\/\/www.moorezilla.com\/blog\/fixing-ubuntu-18-04-and-moving-to-php-fpm\/","title":{"rendered":"Fixing Ubuntu 18.04 and moving to PHP-FPM"},"content":{"rendered":"\n<p>Moved vhost farm to Ubuntu 18.04 on Linode and hit some snags after deciding to move to php-fpm instead of mod-php.<\/p>\n\n\n\n<p>Adding this to apache.conf instead of to each vhost config seems to work fine:<\/p>\n\n\n\n<p><code>&lt;FilesMatch \"\\.php$\"&gt;SetHandler \"proxy:unix:\/var\/run\/php\/php7.2-fpm.sock|fcgi:\/\/localhost\/\"&nbsp;&lt;\/FilesMatch&gt;<br>\n<\/code><\/p>\n\n\n\n<p>Add<\/p>\n\n\n\n<p><code>&lt;If \"-f %{SCRIPT_FILENAME}\"&gt;&lt;\/If&gt;<\/code><\/p>\n\n\n\n<p>around the FilesMatch line to keep non php from being sent to unix sockets and ending up as lines in the Apache error log.<\/p>\n\n\n\n<p>This also seems to work fine in apache.conf to enable http2 for all vhosts:<\/p>\n\n\n\n<p><code>Protocols h2 http\/1.1<\/code><\/p>\n\n\n\n<p>Need to edit children in \/etc\/php\/7.2\/fpm\/pool.d\/www.conf as the default is set to 5. 35 seemed better.<\/p>\n\n\n\n<p>Then <code>a2enmod proxy_fcgi &amp;&amp; a2dismod php7.2<\/code> gets you most of the way there.<\/p>\n\n\n\n<p>Newer kernel prevented php-fpm from launching automatically on reboot, so rolled back to 4.15.18-x86 and this seems to fix php-fpm not launching on a reboot.<\/p>\n\n\n\n<p><code>service php7.2-fpm reload<\/code> never hurts, but shouldn&#8217;t be necessary on reboot.<\/p>\n\n\n\n<p>This was helpful in getting to the bottom of the reboot issue: <a href=\"https:\/\/www.linode.com\/community\/questions\/17135\/php72-fpmservice-failing-after-reboot-nginx-error-502\">https:\/\/www.linode.com\/community\/questions\/17135\/php72-fpmservice-failing-after-reboot-nginx-error-502<\/a><\/p>\n\n\n\n<p>Get rid of red padlock on email sent from server:<\/p>\n\n\n\n<p>smtp_tls_security_level = may<br>smtp_tls_loglevel = 1<br>smtp_tls_CAfile = \/etc\/ssl\/certs\/ca-certificates.crt<\/p>\n\n\n\n<p>LetsEncrypt\/Certbot Fun<\/p>\n\n\n\n<p>sudo .\/letsencrypt-auto &#8211;apache -d <span class=\"highlight\">example.com<\/span> -d <span class=\"highlight\">www.example.com<\/span><\/p>\n\n\n\n<p>Remove cert:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"n\">certbot<\/span> <span class=\"n\">revoke<\/span> <span class=\"o\">--<\/span><span class=\"n\">cert<\/span><span class=\"o\">-<\/span><span class=\"n\">path<\/span> <span class=\"o\">\/<\/span><span class=\"n\">etc<\/span><span class=\"o\">\/<\/span><span class=\"n\">letsencrypt<\/span><span class=\"o\">\/<\/span><span class=\"n\">live<\/span><span class=\"o\">\/<\/span><span class=\"n\">CERTNAME<\/span><span class=\"o\">\/<\/span><span class=\"n\">cert<\/span><span class=\"o\">.<\/span><span class=\"n\">pem<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Moved vhost farm to Ubuntu 18.04 on Linode and hit some snags after deciding to move to php-fpm instead of mod-php. Adding this to apache.conf instead of to each vhost config seems to work fine: &lt;FilesMatch &#8220;\\.php$&#8221;&gt;SetHandler &#8220;proxy:unix:\/var\/run\/php\/php7.2-fpm.sock|fcgi:\/\/localhost\/&#8221;&nbsp;&lt;\/FilesMatch&gt; Add &lt;If &#8220;-f %{SCRIPT_FILENAME}&#8221;&gt;&lt;\/If&gt; around the FilesMatch line to keep non php from being sent to unix &#8230; <a title=\"Fixing Ubuntu 18.04 and moving to PHP-FPM\" class=\"read-more\" href=\"https:\/\/www.moorezilla.com\/blog\/fixing-ubuntu-18-04-and-moving-to-php-fpm\/\" aria-label=\"Read more about Fixing Ubuntu 18.04 and moving to PHP-FPM\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[236],"tags":[],"class_list":["post-3154","post","type-post","status-publish","format-standard","hentry","category-technology"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/posts\/3154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/comments?post=3154"}],"version-history":[{"count":9,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/posts\/3154\/revisions"}],"predecessor-version":[{"id":4057,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/posts\/3154\/revisions\/4057"}],"wp:attachment":[{"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/media?parent=3154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/categories?post=3154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moorezilla.com\/blog\/wp-json\/wp\/v2\/tags?post=3154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}