In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces Windows how to configure Apache to run Python script's CGI mode in the browser, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Now that you have installed Python 2.6 and Eric4 that supports 2.6, you don't want to reinstall 2.5 to continue to configure mod_python under Apache.
Later, an article, Running Python as CGI in Apache in Windows, was discovered about running python script in CGI mode instead of mod_python. And this Python for Windows.
The practice is:
Open httpd.conf, find "# ScriptInterpreterSource Registry", and remove the previous comment # (if you can't find this line, add it yourself)
Find the word "Options Indexes FollowSymLinks" and add "ExecCGI" after it. (the "Indexes" had better be removed, too, because if there is no index.html file under the directory, all the files in the directory list will be displayed, so there is a security vulnerability. If Indexes is removed and there is no index.html file, a Forbidden page will be displayed)
Find "AddHandler cgi-script .cgi" and add .py after it. If you don't have this sentence, you can add "AddHandler cgi-script .py" yourself.
Restart Apache (sometimes restart will cause Apache to die, so people in this situation can stop and then start)
Then create a test.py script
Print "Content-type: text/html"
Print ""
Print ""
Print "Hello World"
Print "pay attention to the second sentence print" can not be less, without this sentence, it will cause a "500Internal Server Error" error.
Running the word http://localhost/test.py World in the browser indicates that it is working properly when it is output.
In addition, some error prompts are as follows:
Without adding ScriptInterpreterSource Registry, a 500Internal Server Error error will occur.
Without the addition of ExecCGI, a 403 Forbidden You don't have permission to access / test.py on http://www.bbqmw.net/qm_yeqm/ this server appears.
If AddHandler cgi-script .py is not added, the content will be displayed in the browser as text text.
Note:
The intention of adding ScriptInterpreterSource Registry is to let Windows use Registry to find the place where Python is installed.
ExecCGI allows python script to run in any directory, because Apache defaults to letting cgi script run in the cgi-bin directory. When I put test.py under htdocs, there will be a problem of 403 Forbidden. So you need to add ExecCGI so that you can run. Py script under htdocs. But there will be security vulnerabilities in ExceCGI. It's safer to use FastCGI. But only if FastCGI is installed.
CGI mode is slower than mod_python mode. So try mod_python mode on other computers in the future.
So much for the CGI mode about how Windows configures Apache to run Python script in the browser. I hope the above can be helpful and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.