[英]exec of a file failed: (2) No such file or directory. Error in apache2
我正在嘗試為apache2服務器版本啟用外部身份驗證:Apache / 2.4.18(Ubuntu)。 但我收到以下錯誤。 我是新來的。 有人可以指出我做錯了嗎? 提前致謝。
“ /home/ubuntu/myauth.php”的exec失敗:(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 [Thu Feb 08 15:53:51.349370 2018] [auth_basic:error] [pid 1232] [client 10.100.1.229:49710] AH01617:失敗(255)用戶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);
}
?>
我想出了答案。 這不是Apache2錯誤。 php文件應以以下內容開頭,以使其可執行。 我在這里找到了答案。
#!/usr/bin/env php
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.