Apache with php-fpm: Difference between revisions

From Alpine Linux
(Previous wiki was not accurate nor current)
m (formatting)
Line 1: Line 1:
===Apache and PHP===
===Apache and PHP===
PHP-FPM is the Fast Process Manager for PHP which runs as a service that spawns PHP processes as needed when files files are requested through the FastCGI interface. Passing this off to the PHP-FPM results in interpreting the PHP files much faster than having Apache spawn new processes each time a page is requested. You can read more about it here [https://php-fpm.org/] .
PHP-FPM is the Fast Process Manager for PHP which runs as a service that spawns PHP processes as needed when files files are requested through the FastCGI interface. Passing this off to the PHP-FPM results in interpreting the PHP files much faster than having Apache spawn new processes each time a page is requested. You can read more about it [https://php-fpm.org/ here].


===Step by Step Instructions===
===Step by Step Instructions===

Revision as of 19:04, 2 December 2021

Apache and PHP

PHP-FPM is the Fast Process Manager for PHP which runs as a service that spawns PHP processes as needed when files files are requested through the FastCGI interface. Passing this off to the PHP-FPM results in interpreting the PHP files much faster than having Apache spawn new processes each time a page is requested. You can read more about it here.

Step by Step Instructions

Install packages

apk add apache2-proxy php8-fpm

Run and Add Services to Startup

rc-service php-fpm8 start rc-update add php-fpm8 rc-service apache2 start rc-update add apache2

Configure Apache

Add the following lines to /etc/apache2/httpd.conf

<FilesMatch \.php$>
   SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>```

Configure PHP-FPM

You can edit the file /etc/php8/php-fpm.conf to suit you needs.

In the configuration you may need to change the default user and group from nobody to another user such as apache:

user = apache
group = apache

Restart apache2 and PHP-FPM

After editing the configuration you must reload related services.

rc-service php-fpm8 reload && rc-service php-fpm8 reload

More info

apache wiki php-fpm manual