php on MacOS HighSierra Server not working (for me)

Discuss server installationa nd configuration issues here

Moderators: gesf, Michalio

Post Reply

  • MacBook Air
  • OSX 10.13.6 (HighSierra)
  • [OSX] Server 5.6.1
  • PHP 7.1.16
  • Safari 11.1.2
  • Chrome 67.0.3396.99
  • A year or so ago, I was playing around with developing a site that utilized some PHP directives, and it was working.
  • I stopped working on it for a (long) while, and since then have certainly upgraded the OS X Server software, and probably the OS as well.
  • I decided to play with it again, but now the PHP directives do not seem to be working and I have not been able to figure out why and (more importantly) how to fix it.
  • The PHP code I used in the original HTML code was of the form:
    • <?php include "html/xxx.html"?>
  • When I wasn't seeing the content I expected (from the to-be included files), I added the following at the very top of the <body> section:
    • <?php echo "Hello"; ?>
  • Nothing (from the PHP standpoint) is showing up, and it was clear from looking at the "network" section of the page inspection console that the files to-be included were not being fetched - but there didn't seem to be any errors indicating that/why PHP wasn't working.
Miscellaneous Details:
  • Modified /private/etc/apache2/httpd.conf:
    • Uncommented the line: LoadModule php7_module libexec/apache2/
    • Changed DocumentRoot specification to match ~/Sites path
    • Modified the <Directory "xxx"> reference just below to also match the ~/Sites path
    • (References: Include /private/etc/apache2/other/*.conf)
    • Uncommented: LoadModule vhost_alias_module libexec/apache2/
    • Uncommented: Include /private/etc/apache2/extra/httpd-vhosts.conf
  • /private/etc/apache2/other/php7.conf contains the following:

    Code: Select all

        <IfModule php7_module>
          AddType application/x-httpd-php .php
          AddType application/x-httpd-php-source .phps
          <IfModule dir_module>
          DirectoryIndex index.html index.php
  • The referenced library is:
    • -rwxr-xr-x 1 root wheel 13429248 Jul 4 09:02 /usr/libexec/apache2/
  • Modified /Library/Server/Web/Config/apache2/httpd_server_app.conf:
    • Changed DocumentRoot specification to match ~/Sites path
  • Modified /private/etc/apache2/extra/httpd-vhosts.conf:
    • Replaced second example directive with one specific for my test site
  • In the Server UI, it shows "Enable PHP" as being checked, and the following command shows the (further) following output:
    • # apachectl -M | grep -in php
      30: php7_module (shared)



    Other steps I should take to try to debug / fix this?

Post Reply