我見過很多其他答案並嘗試過,但他們沒有幫助。Apache:標題前腳本輸出結束
我的Python代碼
#!/usr/bin/env python3
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
它的位置和權限
-rwxr-xr-x. 1 root root 161 May 24 02:42 mypython.py
[[email protected] cgi-bin]# pwd
/var/www/mysite.com/cgi-bin
虛擬主機的conf
[[email protected] cgi-bin]# cat /etc/httpd/sites-available/mysite.com.conf
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot /var/www/mysite.com/public_html
ServerAlias mysite.com
ScriptAlias /cgi-bin/ "/var/www/mysite.com/cgi-bin/"
<Directory /var/www/mysite.com>
Options Indexes FollowSymLinks Includes ExecCGI
AddHandler cgi-script .cgi .py
AllowOverride None
Require all granted
</Directory>
ErrorLog /var/log/httpd/mysite.com/error.log
CustomLog /var/log/httpd/mysite.com/requests.log combined
</VirtualHost>
[[email protected] cgi-bin]#
嘗試訪問時,我收到以下錯誤
[Wed May 24 02:42:53.958318 2017] [cgid:error] [pid 7943] [client 192.168.56.1:52390] End of script output before headers: mypython.py
[Wed May 24 02:42:54.661338 2017] [cgid:error] [pid 7939] [client 192.168.56.1:52391] End of script output before headers: mypython.py
[Wed May 24 02:42:59.383215 2017] [cgid:error] [pid 7940] [client 192.168.56.1:52392] End of script output before headers: mypython.py
如果需要更多信息,請讓我知道。
謝謝。
我已經刪除了空行但它仍然不工作。請幫忙。 –