Solved 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.
 
The way mod_php is loaded and configured in Apache hasn't changed for a long time either.
 
The problem is things keep changing and things don't always work as described.
nah,php+apache configuration is almost the same ...trough years and years
The rest if tweak some change here and there
If there is any problem

pd; the same in FreeBSD,there is no systemd here
 
Maybe, you should try to organize those services inside service jail(s). I used to play with Drupal. I didn't know that nextcloud was in FreeBSD's pkg repos, I need to look at it.
I read that you could incorporate various CMS's. I think I saw Drupal mentioned.
 
Back
Top