简体   繁体   中英

Mac Mojave - can't execute php files with Apache2 web server

Mac OS 10.14 - Mojave:

can't run php web pages on Apache2 server:

Apache Logger file shows PHP module load:

[Sun Nov 04 01:15:44.594704 2018] [mpm_prefork:notice] [pid 31049] AH00163: Apache/2.4.34 (Unix) PHP/7.1.19 configured -- resuming normal operations [Sun Nov 04 01:15:44.594789 2018] [core:notice] [pid 31049] AH00094: Command line: '/usr/sbin/httpd -D SERVER_APP_HAS_DEFAULT_PORTS -D FOREGROUND'

$> php -v on command line shows version 7.1.19:

PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS ) Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Ideas?

I had to add this to private/etc/apache2/httpd.conf (or if you prefer into a .htaccess file, for an example ~/Sites/.htaccess).

# PHP 7 specific configuration
<IfModule php7_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

Uncommenting the line:

LoadModule php7_module libexec/apache2/libphp7.so

at file /etc/apache2/httpd.conf , and restarting apache

apachectl restart

worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM