Apache and PHP

Good day.

Installed Apache24 and php74 with mod_php74.

Created for verification index.php with <?php phpinfo(); ?>.
But apache does not process files .php - just outputs the content.

In log :
Code:
 [mpm_prefork:notice] [pid 4503] AH00163: Apache/2.4.46 (FreeBSD) PHP/7.4.19 mod_perl/2.0.11 Perl/v5.32.1 configured -- resuming normal operations
What you need to tell Apache to process PHP files ?
 
What you need to tell Apache to process PHP files ?
Read pkg info -D mod_php74
Code:
    ******************************************************************************

    Make sure index.php is part of your DirectoryIndex.

    You should add the following to your Apache configuration file:

    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>

    ******************************************************************************

    If you are building PHP-based ports in poudriere(8) or Synth with ZTS enabled,
    add WITH_MPM=event to /etc/make.conf to prevent build failures.

    ******************************************************************************
 
I did exactly that (quote):

pkg install mod_php74
Next, you need to tell Apache to process PHP files by creating a php.conf configuration file under /usr/local/etc/apache24/Includes/ with the following contents;

vim /usr/local/etc/apache24/Includes/php.conf
Code:
<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>
Save the file and restart Apache for the changes to take effect.

this through php-fpm is how it worked :apache process files .php
Code:
LoadModule mpm_event_module libexec/apache24/mod_mpm_event.so

<FilesMatch \.php$>
     SetHandler proxy:fcgi://127.0.0.1:9000
</FilesMatch>
But through php7_module not worked.
 
It's clear.
Perhaps I do not know exactly which modules yet for mod_php enabled.
I decided to run in apache-php the classic way due to the fact that it is not possible to start ocsinventory-server through php-fpm .
 
Perhaps I do not know exactly which modules yet for mod_php enabled.
The module is automatically enabled in httpd.conf when you install www/mod_php74. Using php-fpm is recommended but not all web applications seem to like it.

I decided to run in apache-php the classic way due to the fact that it is not possible to start ocsinventory-server through php-fpm .
Yeah, that can happen. Add that <FilesMatch> bit of code to your vhost configuration, I assume ocsinventory has a <VirtualHost> configuration?
 
The standard Apache error logs. But if you get to see the source of the PHP scripts then it's a safe bet those <FilesMatch> directives haven't been applied correctly. You won't find an error in that case, it just doesn't work as expected.
 
Generally, launched ocsinventory-server through php_fpm.

mod_php is deprecated as FPM is now used by default with httpd in event mode
# mod_php is only used when explicitly enabled or httpd switch to prefork mode

Maybe because of deprecated mod_php <FilesMatch> directives haven't been applied correctly .
 
mod_php isn't deprecated, php-fpm is preferred yes, because it can handle Apache's event mode and that's the preferred way to run Apache. mod_php only works in the "old" prefork mode. If you try to start Apache in event mode and have mod_php loaded it's going to complain about it and fail to start entirely.
 
Back
Top