{"id":1406,"date":"2017-05-03T22:29:58","date_gmt":"2017-05-03T16:59:58","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1406"},"modified":"2017-05-03T22:32:17","modified_gmt":"2017-05-03T17:02:17","slug":"install-apache-php-fpm-ubuntu-16","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-apache-php-fpm-ubuntu-16\/","title":{"rendered":"Install Apache with php-fpm on Ubuntu 16"},"content":{"rendered":"<h3>Install Apache with php-fpm on Ubuntu 16<\/h3>\n<p><strong>Date Posted:03-05-2016<\/strong><\/p>\n<p>Php-fpm is a FastCGI Process Manager which is faster to serve php when compared to mod_php. In this post, we will explain on how to install Apache with php-fpm on Ubuntu 16 host.<\/p>\n<h4>Implementation:<\/h4>\n<p>Let&#8217;s Start with apache2 installation.<\/p>\n<p><code><\/code><code><\/code><code>apt-get install apache2<\/code><\/p>\n<p>By default, <em>ServerName <\/em> might not be added. We may get warning when we try to restart the apache. To fix the error, we will add ServerName to avoid warning. Open the file <em>\/etc\/apache2\/apache2.conf <\/em> and add the following line<\/p>\n<p><code>vi \/etc\/apache2\/apache2.conf<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ServerName 127.0.0.1<\/pre>\n<p>If the server has hostname, we can add the same.<\/p>\n<p>Check for syntax error.<\/p>\n<p><code>apachectl -t<\/code><\/p>\n<p>Enable the service on reboot safe and start the apache service.<\/p>\n<p><code>systemctl enable apache2<\/code><\/p>\n<p><code>systemctl restart apache2<\/code><\/p>\n<h4>Install php-fpm on Ubuntu:<\/h4>\n<p>Install php and libapache2-mode-fastcgi.<\/p>\n<p><code>apt-get -y install libapache2-mod-fastcgi php7.0-fpm php7.0<\/code><\/p>\n<p>Enable the modules.<\/p>\n<p><code>a2enmod actions fastcgi alias<\/code><\/p>\n<p>Update the file\u00a0<em>\/etc\/apache2\/conf-enabled\/php7.0-fpm.conf<\/em><\/p>\n<p><code>vi\u00a0\/etc\/apache2\/conf-enabled\/php7.0-fpm.conf<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;IfModule mod_fastcgi.c&gt;\r\n                AddHandler php7-fcgi .php\r\n                Action php7-fcgi \/php7-fcgi\r\n                Alias \/php7-fcgi \/usr\/lib\/cgi-bin\/php7-fcgi\r\n                FastCgiExternalServer \/usr\/lib\/cgi-bin\/php7-fcgi -socket \/var\/run\/php\/php7.0-fpm.sock -idle-timeout 900 -pass-header Authorization\r\n                &lt;Directory \/usr\/lib\/cgi-bin&gt;\r\n                        Require all granted\r\n                &lt;\/Directory&gt;\r\n&lt;\/IfModule&gt;\r\n<\/pre>\n<p>We can add the same configuration on each virtual host if we dont want to specify globally. The above lines should be placed between\u00a0<em>&lt;virtualhost&gt; &lt;\/virtualhost&gt;.\u00a0<\/em>Default configuration will be\u00a0<em>\/etc\/apache2\/sites-enabled\/00-default.conf.<\/em><\/p>\n<p>Verify the syntax error on apache configurations<\/p>\n<p><code>apachectl -t<\/code><\/p>\n<p>Restart the apache service.<\/p>\n<p><code>systemctl restart apache2<\/code><\/p>\n<p>Restart php-fpm service for the changes into effect.<\/p>\n<p><code>systemctl restart php7.0-fpm<\/code><\/p>\n<p>Create a phpinfo page on the document root\u00a0<em>\/var\/www\/html\/phpinfo\u00a0<\/em>and check the page on info page.<\/p>\n<p><code>vi \/var\/www\/html\/info.php<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\nphpinfo();\r\n?&gt;<\/pre>\n<p>Change the permission of the file<\/p>\n<p><code>chown www-data.www-data \/var\/www\/html\/info.php<\/code><\/p>\n<p>Access the page on phpinfo page on browser. It can be <strong>http:\/\/IPaddress\/info.php.\u00a0<\/strong>Look for the parameter\u00a0<span style=\"color: #ff6600;\"><em>Server API<\/em> \u00a0<span style=\"color: #000000;\">We will see FPM\/FastCGI.<\/span><\/span><\/p>\n<p><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignleft size-full wp-image-1414\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api.png\" alt=\"\" width=\"1192\" height=\"374\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api.png 1192w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api-300x94.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api-768x241.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api-1024x321.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2017\/05\/Server_api-50x16.png 50w\" sizes=\"(max-width: 1192px) 100vw, 1192px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Apache with php-fpm on Ubuntu 16 Date Posted:03-05-2016 Php-fpm is a FastCGI Process Manager which is faster to serve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[278,328,327,274],"class_list":["post-1406","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-apache","tag-fastcgi","tag-fpm","tag-ubuntu","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-mG","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1406"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}