【发布时间】:2017-07-02 13:06:52
【问题描述】:
我是新手,所以看了一些教程。 我有一个 python 脚本作为 first.py
#!/usr/bin/python3
print "Content-type: text/html\n"
print "Hello, world!"
我的电脑上有多个版本的 python。 我无法弄清楚我启用 cgi 的目录,所以我将这段代码粘贴在三个地方
/usr/lib/cgi-bin/first.py
/usr/lib/cups/cgi-bin/first.py
/var/www/html/first.py
现在,当我在终端中运行此代码时,它可以正常工作,但是当我输入时
curl http://localhost/first.py
它只吐出简单的文本并且不执行。
我已将所有权限授予 first.py
我已经通过命令启用并启动了服务器
a2enmod cgi
systemctl restart apache2
请告诉我如何执行以及这里发生了什么? 提前致谢。
【问题讨论】:
标签: python ubuntu apache2 cgi server-side-scripting