我今天安裝了一個新的CentOS 7 x86_64 LAMP服務器。Apache/httpd/var/www/html/.cgi腳本丟500內部服務器錯誤
我在c中編譯了一個簡單的CGI腳本,我將其命名爲test.cgi,並且爲.cgi腳本啓用了AddHandler。然而,每次我嘗試從/ var/www/html目錄加載/test.cgi頁面時,任何簡單的.cgi腳本都會給我一個500內部服務器錯誤頁面。
我測試了腳本在/ var/www/cgi-bin目錄下工作正常。 我的服務器正在運行selinux,而apache/httpd正在使用suEXEC。
編輯:也沒有創建任何額外的用戶燈安裝後,所以在這裏我使用root來做所有的事情。不過,我試圖解決給Apache的用戶/ var/www/html目錄所有權,這並沒有修復悲傷。
這裏的錯誤日誌,你可以看到它給了我一個 '權限被拒絕' 的錯誤:
[Mon Jul 21 15:28:14.336626 2014] [core:notice] [pid 22704] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jul 21 15:28:14.339766 2014] [suexec:notice] [pid 22704] AH: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jul 21 15:28:14.495631 2014] [auth_digest:notice] [pid 22704] AH01757: generating secret for digest authentication ...
[Mon Jul 21 15:28:14.498690 2014] [lbmethod_heartbeat:notice] [pid 22704] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 21 15:28:14.765072 2014] [mpm_prefork:notice] [pid 22704] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 configured -- resuming normal operations
[Mon Jul 21 15:28:14.765186 2014] [core:notice] [pid 22704] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jul 21 15:28:16.027553 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] AH01215: (13)Permission denied: exec of '/var/www/html/index.cgi' failed
[Mon Jul 21 15:28:16.030595 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] End of script output before headers: index.cgi
[Mon Jul 21 15:45:01.586229 2014] [mpm_prefork:notice] [pid 22704] AH00170: caught SIGWINCH, shutting down gracefully
這是我的/ var/www/html等Apache的配置:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options ExecCGI FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
而且我當然激活CGI使用:AddHandler cgi-script .cgi .pl
這是我簡單test1.c文件:
#include <stdio.h>
int main(void) {
puts("Content-Type: text/html; charset=ISO-8859-1\n");
fputs("Hello, World!", stdout);
return 0;
}
輸出是正確:Content-Type: text/html; charset=ISO-8859-1\n\nHello, World!
而且我用gcc編譯它,然後把它的權限777 test.cgi 你知道什麼,我需要做的解決這一問題?
由於提前, Zorgatone
我與Centos 7上的CGI腳本有同樣的問題。我正在嘗試安裝Bugzilla。我已經嘗試了所有不同的權限,包括刪除寫入權限並將所有者切換到apache.apache,但都沒有效果。 –
500錯誤非常普遍...檢查日誌 – user83039