Apache2 在升级至 PHP 8 后以纯文本形式提供 PHP

Apache2 在升级至 PHP 8 后以纯文本形式提供 PHP

我刚刚从 PHP7 升级到 PHP8。现在我的 Apache2 变得很疯狂。服务器要么可以访问,要么无法访问,或者将我的 PHP 显示为纯文本。

php -v

iel@MacBook-Pro-van-Niel apache2 % php -v
PHP 8.0.12 (cli) (built: Oct 21 2021 14:38:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.12, Copyright (c), by Zend Technologies

cat /var/log/apache2/error_log

...
AH00112: Warning: DocumentRoot [/Users/Niel/Websites/vereniging/www/] does not exist
AH00112: Warning: DocumentRoot [/Users/Niel/Websites/voordekunst] does not exist
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MacBook-Pro-van-Niel.local. Set the 'ServerName' directive globally to suppress this message
Failed loading /usr/local/opt/php/lib/php/20200930/opcache.so:  dlopen(/usr/local/opt/php/lib/php/20200930/opcache.so, 9): no suitable image found.  Did find:
    /usr/local/opt/php/lib/php/20200930/opcache.so: code signature in (/usr/local/opt/php/lib/php/20200930/opcache.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    /usr/local/opt/php/lib/php/20200930/opcache.so: stat() failed with errno=22
[Thu Nov 04 01:20:45.021614 2021] [mpm_prefork:notice] [pid 1903] AH00163: Apache/2.4.46 (Unix) PHP/8.0.12 configured -- resuming normal operations
[Thu Nov 04 01:20:45.021680 2021] [core:notice] [pid 1903] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

libphphttpd.conf

#LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so
#LoadModule php7_module libexec/apache2/libphp7.so
#LoadModule php_module libexec/apache2/libphp.so
LoadModule php_module /usr/local/Cellar/php/8.0.12/lib/httpd/modules/libphp.so

这些都不起作用。如何让 PHP8 运行?

答案1

您是否安装了libapache2-mod-php8.0php8.0-fpm 并启用了它?(a2enmod proxy_fcgi setenvifa2enconf php8.0-fpm)如果没有,请启用它。如果您启用了它,那么还有其他问题。

相关内容