0

I am very new to this php-fpm thing, but I decided I need to get into it. I recently migrated to Centos 8, and with it to Apache 2.4.

I have a number of virtual hosts using PHP which worked well until I changed from mod_mpm_prefork to mod_mpm_event. That broke a number of sites.

One site, I have successfully got working by seeking and destroying any references to php_ values in my .htaccess file, since PHP is no longer running as a module. I thought that would be the same for the others.

On all of the other sites, I get a 500 server error. Even when I try a trivial script such as:

Hello
<?php
    die('goodbye');

all I get is a which screen and a 500 server error.

When I look in the error_log file, I see nothing helpful:

GET /index.php HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0"

When I try to access a non-PHP file, it works well.

As far as I can see, the configuration setting relevant to the setup is in conf.d/php.conf:

<IfModule !mod_php5.c>
    <IfModule !mod_php7.c>
        SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
        <FilesMatch \.(php|phar)$>
            SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
        </FilesMatch>
    </IfModule>
</IfModule>

If I comment out the SetHandler line the pages work, without PHP of course. I really don’t know how to check whether this line is correct.

I’m sure the fix is simple, but how can I find the cause of the 500 error, and what might be the case of not running a PHP script?

Manngo
  • 115
  • 1
  • 8
  • What do you have left in the Apache configuration that concerns PHP? – Gerard H. Pille Jul 12 '20 at 10:05
  • @GerardH.Pille The file `conf.d/php.conf` has the following: ` SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost `. When I comment it out, the pages load (without PHP, of course). – Manngo Jul 12 '20 at 11:31
  • Can you please add tthat to your question, what I see in your comments can never work. – Gerard H. Pille Jul 12 '20 at 11:35
  • @GerardH.Pille Done – Manngo Jul 12 '20 at 11:40
  • Have a look here, their php.conf does it somewhat differently: https://tecadmin.net/install-apache-php-fpm-centos-8/ – Gerard H. Pille Jul 12 '20 at 11:51
  • The contents of the php-fpm error log may be of interest too. – Gerard H. Pille Jul 12 '20 at 11:59
  • @GerardH.Pille Where do I find that log? `locate` doesn’t find it. – Manngo Jul 12 '20 at 12:00
  • Perhaps you didn't start php-fpm? Otherwise, check the php-fpm configuration. ; Default Value: log/php-fpm.log error_log = syslog – Gerard H. Pille Jul 12 '20 at 12:14
  • "I’m sure the fix is simple", you may be right, but it can be tricky to find the fix. – Gerard H. Pille Jul 12 '20 at 13:25
  • Something I said? – Gerard H. Pille Jul 14 '20 at 08:36
  • @GerardH.Pille OK, finally found it. Looking in `/var/log/php-fpm/error.log` I found that it was crashing because it couldn’t find a file called from Line 0 in Unknown, which makes it hard to trouble shoot. It was due to my using `SetEnv PHP_VALUE` in `.htaccess` to `auto_prepend` a file. What I hadn’t realised was that this would apply to all of my virtual sites, so when the file wasn’t there for another site, php-fpm would overreact. When I finally migrated to `.user.ini` for everything it cleaned up the problem, and everything works as intended. – Manngo Jul 14 '20 at 20:25

0 Answers0