Apache & php

I've seen numerous guides to getting php working with Apache and am having problems displaying

<?php phpinfo(); ?>

What is the minimum I need to install?

Is this sufficient?

sh:
cat <<EOF >/usr/local/etc/apache24/Includes/php.conf
<IfModule dir_module>
    DirectoryIndex index.php index.html

    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
</IfModule>
EOF
 
cat <<EOF >/usr/local/etc/apache24/Includes/php.conf
Put it in /usr/local/etc/apache24/modules.d/001_php.conf
Not going to change how it works, but it keeps things a bit more organized. Use the Includes/ directory for your website configurations.

Note that this configuration assumes you have one of the mod_php* modules installed. For PHP-FPM the configuration is a bit different.
 
I've seen numerous guides to getting php working with Apache and am having problems displaying

<?php phpinfo(); ?>

What is the minimum I need to install?

Is this sufficient?

sh:
cat <<EOF >/usr/local/etc/apache24/Includes/php.conf
<IfModule dir_module>
    DirectoryIndex index.php index.html

    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
</IfModule>
EOF
Search google for "freebsd famp setup"
The old and good apache+php+mysql combo
 
Note to self.

Code:
#install pkgs
cat << EOF | xargs pkg install -y 
apache24
mod_php84
php84-extensions
EOF
       
#configure php

cat <<EOF >/usr/local/etc/apache24/modules.d/001_php.conf                                                                                                                                                       
<IfModule dir_module>
    DirectoryIndex index.php index.html                                                                                                                                                                                                         
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
</IfModule>   
EOF
         
echo '<?php phpinfo(); ?>' > /usr/local/www/apache24/data/info.php

sysrc apache24_enable=YES

service apache24 start

This should be enough to show 192.168.1.22/info.php
1773144728338.png
 
so is apache, which has been on version 2.4 for WAY over a decade (I'm also using nginx, respectively angie FWIW)...
But I guess OP hasn't even tried to follow the dead-simple instructions in the handbook.
My problem wasn't about getting apache running but about how to get it working properly with php. The handbook mentions php74.

In fact it is quite useless when it comes to configuring interaction between apache and php.
 
Back
Top