KB Article #180979

PHP is not enabled in Apache

Problem

  • API Portal install exists with "PHP could not be found as a module of Apache. Please configure it and restart the installation.".
  • When "httpd -M | grep php7_module" is executed, php7_module is not listed.

Resolution

"php7_module" is an Apache module that is responsible for rendering PHP7 pages. It must be enabled in order to install API Portal.

  1. Check the location of Apache's PHP7 module:

    find / -name *php7.s
  2. Open httpd.conf in order to edit it. If you don't know where it is, you can check its location by:
    echo "$(httpd -V | grep -Po '(?<=HTTPD_ROOT=").*(?=")')/$(httpd -V | grep -Po '(?<=SERVER_CONFIG_FILE=").*(?=")')"
  3. Above the line Include conf.modules.d/*, remove any existing entry for PHP and add:
    LoadModule php7_module <absolute file path of php7.so from step 1>
    AddType text/html .php
    DirectoryIndex index.php
    <IfModule  mod_php7.c>
        <FilesMatch \.php$>
            SetHandler application/x-httpd-php
        </FilesMatch>
    </IfModule>
  4. Save the file and restart Apache:
    systemctl restart httpd
  5. Check if php7_module is now active:
    httpd -M | grep php7_module