{"id":2537,"date":"2015-11-17T09:46:49","date_gmt":"2015-11-17T09:46:49","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2537"},"modified":"2015-11-17T09:46:49","modified_gmt":"2015-11-17T09:46:49","slug":"running-php-as-fastcgi-with-apache-2-x-on-ubuntu-12-x-and-later","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2015\/11\/17\/running-php-as-fastcgi-with-apache-2-x-on-ubuntu-12-x-and-later\/","title":{"rendered":"Running PHP as FastCGI with Apache 2.x on Ubuntu 12.x and later"},"content":{"rendered":"<p>The instructions given below are to be run from the terminal. This is the only list of instructions which actually worked. I have reproduced the steps as a simple list to be followed based on the post made by <a href=\"http:\/\/askubuntu.com\/users\/257216\/jdawgg\" target=\"_blank\">JDawgg<\/a>.<\/p>\n<p><strong>Install Apache Mpm worker and PHP5 FPM modules:<\/strong><\/p>\n<pre>sudo apt-get install apache2-mpm-worker\r\nsudo apt-get install libapache2-mod-fastcgi php5-fpm\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Enable\/Disable mods in Apache<\/strong><\/p>\n<pre>sudo a2dismod php5 mpm_prefork\r\nsudo a2enmod actions fastcgi alias mpm_worker\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Create php5.fcgi and provide the correct user rights.<\/strong><\/p>\n<pre>sudo touch \/usr\/lib\/cgi-bin\/php5.fcgi\r\nsudo chown -R www-data:www-data \/usr\/lib\/cgi-bin\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Add a configuration for php5.fpm in Apache2<\/strong><\/p>\n<pre>sudo vi \/etc\/apache2\/conf-available\/php5-fpm.conf\r\n<\/pre>\n<p>with the contents:<\/p>\n<pre>&lt;IfModule mod_fastcgi.c&gt;\r\nAddHandler php5.fcgi .php\r\nAction php5.fcgi \/php5.fcgi\r\nAlias \/php5.fcgi \/usr\/lib\/cgi-bin\/php5.fcgi\r\nFastCgiExternalServer \/usr\/lib\/cgi-bin\/php5.fcgi -socket \/var\/run\/php5-fpm.sock -pass-header Authorization -idle-timeout 3600\r\n&lt;Directory \/usr\/lib\/cgi-bin&gt;\r\nRequire all granted\r\n&lt;\/Directory&gt;\r\n&lt;\/IfModule&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Enable php5-fpm module in Apache2<\/strong><\/p>\n<pre>sudo a2enconf php5-fpm\r\n<\/pre>\n<p><strong>Restart Apache2 and PHP-FPM<\/strong><\/p>\n<pre>sudo service apache2 restart\r\nsudo service php5-fpm restart\r\n<\/pre>\n<p>If you do a phpinfo() on a test page, then the Server API information should show FPM\/FastCGI instead of the usual Apache 2.0 Handler.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/11\/phpinfo-2015-11-17-15-10-17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-2539\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/11\/phpinfo-2015-11-17-15-10-17-620x189.png\" alt=\"phpinfo() 2015-11-17 15-10-17\" width=\"620\" height=\"189\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/11\/phpinfo-2015-11-17-15-10-17-620x189.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/11\/phpinfo-2015-11-17-15-10-17-300x92.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/11\/phpinfo-2015-11-17-15-10-17.png 636w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>The instructions given below are to be run from the terminal. This is the only list of instructions which actually worked. I have reproduced the <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2015\/11\/17\/running-php-as-fastcgi-with-apache-2-x-on-ubuntu-12-x-and-later\/\" title=\"Running PHP as FastCGI with Apache 2.x on Ubuntu 12.x and later\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,298],"tags":[],"class_list":["post-2537","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apachephp","category-linux"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2537"}],"version-history":[{"count":3,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2537\/revisions"}],"predecessor-version":[{"id":2541,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2537\/revisions\/2541"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2542"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}