文件的exec失败:(2)没有这样的文件或目录。 apache2出错

时间:2018-02-08 15:41:41

标签: php apache2

我正在尝试为apache2服务器版本启用外部身份验证:Apache / 2.4.18(Ubuntu)。但我收到以下错误。我对此很陌生。有人可以指出我做错了什么吗?提前谢谢。

  

/home/ubuntu/myauth.php'的执行官;失败:(2)没有这样的文件或   目录[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]:用户gert失败(255)[2008年2月2日星期四   15:53:51.349370 2018] [auth_basic:error] [pid 1232] [客户端   10.100.1.229:49710] AH01617:用户gert:" /":密码不匹配

的身份验证失败

我的apache2.conf如下

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

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

ServerName 192.168.58.21

000-default.conf文件如下

<VirtualHost *:80>

    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

    <Directory "/var/www/html">
        AuthType Basic
        AuthName "Restricted Content"
        AuthBasicProvider external
        AuthExternal phptest
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Directory>

</VirtualHost>

Myauth.php文件如下:

#!/usr/bin/php5
<?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);
}
?> 

1 个答案:

答案 0 :(得分:0)

我想出了答案。它不是Apache2错误。 php文件应该从以下开始,以使其可执行。我找到了答案here

#!/usr/bin/env php