{"id":1406,"date":"2017-05-03T22:29:58","date_gmt":"2017-05-03T16:59:58","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1406"},"modified":"2026-10-12T14:23:35","modified_gmt":"2026-10-12T08:53:35","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":"\n<h3 class=\"wp-block-heading\">Introduction<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PHP-FPM (FastCGI Process Manager) is an alternative to the traditional <code>mod_php<\/code> method for serving PHP applications through Apache. It provides better process management and can improve PHP application performance, especially when handling multiple requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we will explain how to install and configure <strong>Apache with PHP-FPM on an Ubuntu 16 server<\/strong> and verify that PHP requests are being processed through FPM\/FastCGI.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting, make sure you have:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>An Ubuntu 16 server.<\/li>\n\n\n\n<li>Root or sudo access to the server.<\/li>\n\n\n\n<li>Basic knowledge of Apache and Linux commands.<\/li>\n\n\n\n<li>A valid server hostname or IP address.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Implementation<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Install Apache<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install Apache using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-get install apache2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">By default, the <code>ServerName<\/code> directive may not be configured. This can result in a warning when restarting Apache.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Apache configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/apache2\/apache2.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ServerName 127.0.0.1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the server has a hostname, you can specify the hostname instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the Apache configuration for syntax errors:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apachectl -t<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enable Apache to start automatically after a reboot:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable apache2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Apache:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart apache2<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Install PHP-FPM<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install PHP 7.0, PHP-FPM, and the required Apache FastCGI module:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-get -y install libapache2-mod-fastcgi php7.0-fpm php7.0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enable the required Apache modules:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a2enmod actions fastcgi alias<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Configure Apache with PHP-FPM<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Open the PHP-FPM Apache configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/apache2\/conf-enabled\/php7.0-fpm.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;IfModule mod_fastcgi.c>\n    AddHandler php7-fcgi .php\n    Action php7-fcgi \/php7-fcgi\n    Alias \/php7-fcgi \/usr\/lib\/cgi-bin\/php7-fcgi\n    FastCgiExternalServer \/usr\/lib\/cgi-bin\/php7-fcgi -socket \/var\/run\/php\/php7.0-fpm.sock -idle-timeout 900 -pass-header Authorization\n\n    &lt;Directory \/usr\/lib\/cgi-bin>\n        Require all granted\n    &lt;\/Directory>\n&lt;\/IfModule><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same configuration can also be added inside an individual <code>&lt;VirtualHost&gt;<\/code> block if PHP-FPM needs to be configured only for a specific virtual host.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default Apache virtual host configuration is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/etc\/apache2\/sites-enabled\/000-default.conf<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The exact Apache\/PHP-FPM package and configuration can vary depending on the Ubuntu\/PHP version being used.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\">Step 4: Verify the Apache Configuration<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Check the Apache configuration for syntax errors:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apachectl -t<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the syntax is correct, restart Apache:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart apache2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart the PHP-FPM service:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart php7.0-fpm<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 5: Create a PHP Information Page<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Create a PHP information file in the Apache document root:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/var\/www\/html\/info.php<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nphpinfo();\n?><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Change the ownership of the file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chown www-data:www-data \/var\/www\/html\/info.php<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now access the following URL from a browser:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/IPaddress\/info.php<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On the PHP information page, search for <strong>Server API<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If PHP-FPM is configured correctly, it should display:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FPM\/FastCGI<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This confirms that PHP is being processed through PHP-FPM instead of <code>mod_php<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we explained how to install <strong>Apache with PHP-FPM on Ubuntu 16<\/strong>. We configured Apache to communicate with PHP-FPM through the FastCGI interface and verified the configuration using a PHP information page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using PHP-FPM with Apache provides an efficient way to process PHP requests and gives administrators better control over PHP worker processes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FAQs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. What is PHP-FPM?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PHP-FPM stands for <strong>PHP FastCGI Process Manager<\/strong>. It is used to process PHP requests through the FastCGI protocol.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Why use PHP-FPM with Apache?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PHP-FPM provides improved process management and can handle PHP requests efficiently compared with the traditional <code>mod_php<\/code> approach.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. How can I verify that PHP-FPM is working?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create a PHP information page using <code>phpinfo()<\/code> and check the <strong>Server API<\/strong> parameter. It should show <code>FPM\/FastCGI<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Article<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/setup-password-authentication-for-apache2-in-centos\/\">Setup password authentication for Apache2 in Centos &#8211; Pheonix Solutions<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-and-configure-php-with-nginx-on-centos7\/\">How to install and configure PHP with Nginx on centos7 \u2013 Pheonix Solutions<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Have a technology challenge or looking for the right solution for your business? Our team can help you with&nbsp;<strong>cloud, DevOps, development, infrastructure, design, and more<\/strong>. Feel free to reach out to our experts&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/contact\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction PHP-FPM (FastCGI Process Manager) is an alternative to the traditional mod_php method for serving PHP applications through Apache. It [&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_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":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"predecessor-version":[{"id":11747,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1406\/revisions\/11747"}],"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}]}}