Configure Apache mod_python in Ubuntu to directly download files that cannot be parsed in Firefox.

Source: Internet
Author: User

I encountered some problems while reading the mod_python installation documentation. Now I have solved them. I 'd like to share with you.

My system is Ubuntu 9.04. Use apt-get to install Apache and mod_python


Here is the Chinese Document of mod_python for my reference.

In section 2.3.2 configure Apache, the content in the/etc/apache2/mod-available/python. Load file is

LoadModule python_module /usr/lib/apache2/modules/mod_python.so

Create a python. conf file under the/etc/apache2/mod-available/directory to configure the python-related application information.

<Directory/var/wwwt>

Addhandler mod_python. py

Pythonhandler mptest

Pythondebug on

Addtype text/html; Qs = 1.0. py

Addtype text/html; Qs = 0.9. html

Addtype text/html; Qs = 0.8. txt

</Directory>

The last three lines are important. For example, when I use Firefox to browse the file, I cannot parse the file but directly download the file.

Here I refer to 2 articles to solve 1 2

Addtype text/html; Qs = 1.0. py

Addtype text/html; Qs = 0.9. html

Addtype text/html; Qs = 0.8. txt

Then use the ln command to create a connection to the two files to/etc/apache2/mod-enabled /.

Run the/etc/init. d/apache2 restart command to restart Apache.

Create a file mytest. py under/var/www /.

Content is

From mod_python import Apache

Def handler (req ):

Req. Write ("Hello world! ")

Return Apache. OK

Test it in the browser. If you see hello World! It is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.