title: exec of a file failed: (2) No such file or directory. Error in apache2
body: <p>I'm trying to enable external authentication for apache2 Server version: Apache/2.4.18 (Ubuntu). But I'm getting the following error. i'm new to this. Can someone point out what I'm doing wrong? Thanks in advance.</p>
  
  <blockquote>
    <p>exec of '/home/ubuntu/myauth.php' failed: (2) No such file or
    directory [Thu Feb 08 15:53:51.349279 2018] [authnz_external:error]
    [pid 1232] [client 10.100.1.229:49710] AuthExtern phptest
    [/home/ubuntu/myauth.php]: Failed (255) for user gert [Thu Feb 08
    15:53:51.349370 2018] [auth_basic:error] [pid 1232] [client
    10.100.1.229:49710] AH01617: user gert: authentication failure for "/": Password Mismatch</p>
  </blockquote>
  
  <p>My apache2.conf is as follows</p>
  
  <pre><code>Mutex file:${APACHE_LOCK_DIR} default
  PidFile ${APACHE_PID_FILE}
  Timeout 300
  KeepAlive On
  MaxKeepAliveRequests 100
  KeepAliveTimeout 5
  User ${APACHE_RUN_USER}
  Group ${APACHE_RUN_GROUP}
  HostnameLookups Off
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  IncludeOptional mods-enabled/*.load
  IncludeOptional mods-enabled/*.conf
  Include ports.conf
  
  &lt;Directory /&gt;
      Options FollowSymLinks
      AllowOverride None
      Require all denied
  &lt;/Directory&gt;
  
  &lt;Directory /usr/share&gt;
      AllowOverride None
      Require all granted
  &lt;/Directory&gt;
  
  &lt;Directory /var/www/&gt;
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
  &lt;/Directory&gt;
  
  AccessFileName .htaccess
  
  &lt;FilesMatch "^\.ht"&gt;
      Require all denied
  &lt;/FilesMatch&gt;
  
  LogFormat "%v:%p %h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  LogFormat "%h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%h %l %u %t \"%r\" %&gt;s %O" common
  LogFormat "%{Referer}i -&gt; %U" referer
  LogFormat "%{User-agent}i" agent
  
  IncludeOptional conf-enabled/*.conf
  IncludeOptional sites-enabled/*.conf
  
  ServerName 192.168.58.21
  </code></pre>
  
  <p>The 000-default.conf file is as follows</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      LoadModule authnz_external_module modules.d/mod_authnz_external.so
      AddExternalAuth phptest /home/ubuntu/myauth.php
      SetExternalAuthMethod phptest pipe
  
      &lt;Directory "/var/www/html"&gt;
          AuthType Basic
          AuthName "Restricted Content"
          AuthBasicProvider external
          AuthExternal phptest
          AuthUserFile /etc/apache2/.htpasswd
          Require valid-user
      &lt;/Directory&gt;
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Myauth.php file is as follows:</p>
  
  <pre><code>#!/usr/bin/php5
  &lt;?php
  // Read from stdin. First line is the username, second line is the password.
  $handle = fopen ("php://stdin","r");
  $username = trim(fgets($handle));
  $password = trim(fgets($handle));
  
  // Check the username/password. Below is a very simple example, write your own!
  // Probably you want to create a query to some database, add salts, etc.
  if($username != 'gert' || $password != 'mypassword'){
      # Output to stdout/stderr will be included in the Apache log for debugging purposes
      echo "wrong username or password for user $username\n";
      # In case of a failure, sleep a few seconds to slowdown bruteforce attacks.
      sleep (3);
      exit (1);
  } else {
      echo "username/password allowed for user $username\n";
      exit (0);
  }
  ?&gt; 
  </code></pre>