Apache2 Python 脚本在浏览器中不是 运行
Apache2 Python script not running in browser
我知道在几个论坛中有大量的讨论,但不幸的是 none 的答案和建议对我有用。我想执行一个非常简单的 Python 脚本并在浏览器中查看输出。我按照 http://raspberrywebserver.com/cgiscripting/writing-cgi-scripts-in-python.html.
的说明进行操作
我的 "hello.py" Python 文件位于 /usr/lib/cgi-bin。当从终端 运行 将其设置为 python hello.py
时,一切正常。我的 Apache2 网络服务器似乎也 运行 完美如其所示:
"有效!这是该服务器的默认网页。网络服务器软件正在 运行ning,但尚未添加任何内容。"
在浏览器中输入 Raspberry Pi (xxx.xxx.x.xx) 的 IP 时。
当我将路径添加到我的 Python 文件时,如 192.168.0.12/cgi-bin/hello.py 它说 404 - Not Found.
我的 Apache 配置文件如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
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/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
目前有什么想法吗?
终于解决了。我没有注意到我 运行 Lighttpd 在端口 80 上,Apache 也在监听那个端口。通过将 Apache 设置为侦听端口 8080,它可以完美运行。尽管如此,我还是要感谢所有为解决我的问题做出贡献的人。
我知道在几个论坛中有大量的讨论,但不幸的是 none 的答案和建议对我有用。我想执行一个非常简单的 Python 脚本并在浏览器中查看输出。我按照 http://raspberrywebserver.com/cgiscripting/writing-cgi-scripts-in-python.html.
的说明进行操作我的 "hello.py" Python 文件位于 /usr/lib/cgi-bin。当从终端 运行 将其设置为 python hello.py
时,一切正常。我的 Apache2 网络服务器似乎也 运行 完美如其所示:
"有效!这是该服务器的默认网页。网络服务器软件正在 运行ning,但尚未添加任何内容。"
在浏览器中输入 Raspberry Pi (xxx.xxx.x.xx) 的 IP 时。
当我将路径添加到我的 Python 文件时,如 192.168.0.12/cgi-bin/hello.py 它说 404 - Not Found.
我的 Apache 配置文件如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
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/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
目前有什么想法吗?
终于解决了。我没有注意到我 运行 Lighttpd 在端口 80 上,Apache 也在监听那个端口。通过将 Apache 设置为侦听端口 8080,它可以完美运行。尽管如此,我还是要感谢所有为解决我的问题做出贡献的人。