I'll assume:
- SO: Debian GNU/Linux
localhost.holomodor
: host that will use PHP-FPM. Located in /var/www/holomodor/
- version of PHP:
8.1
- version of Apache:
2.4
- PHP-FPM/Apache proxy method (unix socket or TCP socket): TCP socket
- Install both,
mod_php
and php-fpm
:
user@debian:~$ sudo apt install -y libapache2-mod-php8.1 php8.1-fpm
- Create a virtualhost called
localhost.holomodor
in Apache just creating a new file on virtualhost configurations files directory of Apache (default: /etc/apache2/sites-available/
):
<VirtualHost localhost.holomodor:80>
ServerAdmin user@email
ServerName localhost.holomodor
ServerAlias www.localhost.holomodor
DocumentRoot /var/www/holomodor
ErrorLog /var/www/holomodor/error.log # plz change this
CustomLog /var/www/holomodor/access.log combined # plz change this
<Directory /var/www/holomodor>
Options Indexes MultiViews
AllowOverride None
Require all granted
# Begin FPM config
<FilesMatch \.php$>
# TCP socket example (port):
# SetHandler proxy:fcgi://127.0.0.1:9000
# or, unix socket example (file):
# SetHandler "proxy:unix:/var/run/php/php8.1-fpm.sock|fcgi://localhost.holomodor/"
<If "-f %{REQUEST_FILENAME}">
SetHandler proxy:fcgi://127.0.0.1:9000
</If>
</FilesMatch>
# end FPM config
</Directory>
</VirtualHost>
- Create a FPM pool for
localhost.holomodor
on PHP-FPM pool configuration directory (default: /etc/php/8.1/fpm/pool.d/
):
# rename default config
# remove default (unused) localhost.conf pool
user@debian:~$ sudo cp /etc/php/8.1/fpm/pool.d/localhost.conf /etc/php/8.1/fpm/pool.d/localhost-holomodor.conf \
sudo rm /etc/php/8.1/fpm/pool.d/localhost.conf
- Changes on
localhost.holomodor
PHP-FPM pool /etc/php/8.1/fpm/pool.d/localhost-holomodor.conf
4.1 Set the TCP socket address for requests (and problably customize your pool with other things):
# ...
listen = 127.0.0.1:9000
# ...
4.2 Change the pool name ([localhost]
) to localhost.holomodor
on this same file:
# ...
[localhost.holomodor]
# ...
- Enable
localhost.holomodor
virtualhost; Enable Apache modules: mod_php
, mod_proxy
and mod_proxy_fcgi
; restart Apache and PHP-FPM services:
user@debian:~$ sudo a2ensite localhost.holomodor \
sudo systemctl restart apache2 php8.1-fpm
VoilĂ http://localhost.holomodor:80