
我的 apache 設定錯誤。我的腳本不想被執行,瀏覽器試圖將其作為文件下載。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName president.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi/
<Directory /var/www/cgi/>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
AddHandler cgi-script .cgi .pl
</Directory>
- 腳本擁有
www-data:www-data
權限755
並且可以執行 (+x
)。 - 舍邦例如
#!/usr/bin/perl
。 - 錯誤日誌是空的。
答案1
問題解決了!
我刪除所有內容Require all granted
(僅適用於 Apacvhe 2.4+)並貼上:
Order allow,deny
allow from all
我還移動AddHandler cgi-script .cgi .pl
到 DocumentRoot 目錄描述