jide / clamp

Command Line Apache MySQL PHP
http://jide.github.io/clamp
GNU General Public License v2.0
79 stars 9 forks source link

AH00534: httpd: Configuration error: No MPM loaded. #30

Closed zietbukuel closed 6 years ago

zietbukuel commented 6 years ago

I can't get clamp to work after updating PHP to 7.1. I'm a bit lost here so any help is appreciated.

This is my clamp.json file:

{
  "address": "localhost",
  "memory": "256M",
  "database": "db",
  "apache": {
    "commands": {
      "httpd": "sudo httpd"
    },
    "options": {
      "<Directory": " '{{$cwd}}'>",
      "AllowOverride": "All",
      "</Directory>": "",
      "servername": "{{$.address}}",
      "listen": "80",
      "documentroot": "'{{$cwd}}'",
      "serverroot": "'{{$cwd}}'",
      "pidfile": "'{{$cwd}}/.clamp/tmp/httpd.pid'",
      "defaultruntimedir": "'{{$cwd}}/.clamp/tmp",
      "loglevel": "info",
      "errorlog": "'{{$cwd}}/.clamp/logs/apache.error.log'",
      "customlog": "'{{$cwd}}/.clamp/logs/apache.access.log' common",
      "addtype": "application/x-httpd-php .php",
      "directoryindex": "index.html index.php",
      "setenv": "LOCAL_SERVER true",
      "user": "`whoami`",
      "autoopen": false,
      "group": "_www",
      "loadmodule": {
        "authz_host_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_authz_host.so",
        "authz_core_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_authz_core.so",
        "dir_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_dir.so",
        "env_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_env.so",
        "mime_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_mime.so",
        "log_config_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_log_config.so",
        "rewrite_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_rewrite.so",
        "php7_module": "$(brew --prefix php71)/libexec/apache2/libphp7.so",
        "unixd_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_unixd.so"
      },
      "php_admin_value": "{{$.php.options}}"
    }
  },
  "host": {
    "options": {
      "127.0.0.1": "{{$.address}}"
    }
  },
  "mysql": {
    "commands": {
      "mysql": "$(brew --prefix mariadb)/bin/mysql",
      "mysqld": "$(brew --prefix mariadb)/bin/mysqld",
      "mysqladmin": "$(brew --prefix mariadb)/bin/mysqladmin",
      "mysqldump": "$(brew --prefix mariadb)/bin/mysqldump",
      "mysql_install_db": "$(brew --prefix mariadb)/bin/mysql_install_db"
    },
    "databases": [
      "{{$.database}}"
    ],
    "options": {
      "bind-address": "127.0.0.1",
      "port": "3306",
      "lower_case_table_names": 2,
      "basedir": "$(brew --prefix mariadb)",
      "datadir": "'{{$cwd}}/.clamp/data'",
      "socket": "'{{$cwd}}/.clamp/tmp/mysql.sock'",
      "pid-file": "'{{$cwd}}/.clamp/tmp/mysql.pid'",
      "log_error": "'{{$cwd}}/.clamp/logs/mysql.error.log'",
      "max_binlog_size": "10M",
      "max_allowed_packet": "32M"
    }
  },
  "php": {
    "options": {
      "memory_limit": "{{$.memory}}",
      "pdo_mysql.default_socket": "{{$.mysql.options.socket}}",
      "mysql.default_socket": "{{$.mysql.options.socket}}",
      "mysqli.default_socket": "{{$.mysql.options.socket}}"
    }
  }
}

Even if I add this line to my clamp.json file it still complains about an MPM module not being loaded:

"mpm_prefork_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_mpm_prefork.so",

As you can see, I've installed apache with homebrew because I need PHP 7 but I don't want to upgrade my Mac yet.

alanfluff commented 6 years ago

Hey @zietbukuel, in case this helps, I fixed clamp for me, with PHP 7, with this temporary hack.

zietbukuel commented 6 years ago

@alanfluff It still fails with the same message. /usr/libexec/apache2/libphp7.so doesn't even exists in my system. Mine is in /usr/local/opt/php71/libexec/apache2/libphp7.so

alanfluff commented 6 years ago

Sorry to hear that @zietbukuel :/

rqelibari commented 6 years ago

@zietbukuel mpm_prefork_module defines a way how apache handles request. There are other modules, which you can choose from (e.g. mpm_worker_module or mpm_event_module). The php7 module seems to require mpm_prefork_module. Can you run the following command:

find . -iname "*prefork*.so" 2> /dev/null 

Does this yield any output?

zietbukuel commented 6 years ago

Thanks @rqelibari but I'm not sure what would that be a problem because $(brew --prefix php71) get's translated to /usr/local/opt/php71. I tried it anyway, but it still fails. Thanks again for your suggestion.

rqelibari commented 6 years ago

After some investigation I found the cause of the error.

The Problem

As the error message states, Apache complains about a missing mpm module. The usual solution would be to add a line like LoadModule mpm_prefork_module modules/mod_mpm_prefork.so to the configuration file. In the case of clamp this is not sufficient though as there is also another problem. clamp uses the lower case -c option of the httpd binary to provide the options on the command line. The the lower case -c option loads the configuration provided at the last stage of configuration of Apache. But the mpm_*_module needs to be loaded at one of the earlier stages e.g. by providing it with the upper case -C option.

The Solution

As this is a rather special use case, the solution will be to add a new line in the options section of clamp.json. So just add "\" -C \"loadmodule mpm_prefork_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_mpm_prefork.so" above the usual loadmodule key:

    "group": "somegroup",
    "\" -C \"loadmodule mpm_prefork_module": "$(brew --prefix httpd)/lib/httpd/modules/mod_mpm_prefork.so",
    "loadmodule": {
        "...": "..."
    },