【发布时间】:2017-05-25 07:47:44
【问题描述】:
我看过许多其他答案并尝试过,但它们没有帮助。
我的 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
[root@server cgi-bin]# pwd
/var/www/mysite.com/cgi-bin
虚拟主机配置
[root@server 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>
[root@server 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
如果需要更多信息,请告诉我。
谢谢。
【问题讨论】: