FreeBSD 14
Sponsored Link

Apache httpd : Use PHP Scripts2024/01/30

 

Configure Apache httpd to use PHP scripts.

[1]

Install PHP, refer to here.

[2] Configure Apache httpd.
root@www:~ #
vi /usr/local/etc/apache24/httpd.conf
# line 129 : uncomment

LoadModule proxy_module libexec/apache24/mod_proxy.so
# line 133 : uncomment

LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so
root@www:~ #
vi /usr/local/etc/php-fpm.d/www.conf
# line 45 : change

listen =
/var/run/php-fpm.sock

# line 57, 58 : uncomment

listen.owner = www
listen.group = www
# add setting within the Virtualhost section where you want to configure PHP

root@www:~ #
vi /usr/local/etc/apache24/extra/httpd-ssl.conf
.....
.....
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/"
    </FilesMatch>
</VirtualHost>

root@www:~ #
sysrc php_fpm_enable="YES"

root@www:~ #
service php-fpm start

Performing sanity check on php-fpm configuration:
[30-Jan-2024 11:10:13] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful

Starting php_fpm.

root@www:~ #
service apache24 reload
# create a test page

root@www:~ #
echo '<?php phpinfo(); ?>' > /usr/local/www/apache24/data/info.php

[3] Verify to access to PHPInfo test page from any client computer.
Matched Content