How to deploy Quixote using Apache + mod_wsgi

Source: Internet
Author: User
After a few days of hard work, I finally got it done. I would like to record it. If some Daniel finds that the method is inappropriate, please correct it. I feel excited to myself ........
The process is as follows:
Assume that you have installed python2.5 and Quixote.
1. Installing apache2.2
2. Download mod_wsgi.so
3. copy to the modlues directory of Apache
4. Prepare the script to connect mod_wsgi to Quixote, Code As follows:

Because QWIP must support multi-thread publisher, it must inherit publisher to implement multi-thread support. The implementation example is in the demo folder of Quixote. The Code is as follows:

 

Multi thread support
1 # Multi thread support
2 Import Thread
3 Class Threadedpublisher (publisher ):
4 Is_thread_safe = True
5 Def   _ Init __ (Self, root_namespace, config = None ):
6 Publisher. _ Init __ (Self, root_namespace, config)
7 Self. _ request_dict = {}
8 Def _ Set_request (self, request ):
9 Self. _ request_dict [thread. get_ident ()] = Request
10 Def _ Clear_request (Self ):
11 Try :
12 Del Self. _ request_dict [thread. get_ident ()]
13 Except Keyerror:
14 Pass
15 Def Get_request (Self ):
16 Return Self. _ request_dict.get (thread. get_ident ())


Note that the line is_thread_safe = true is not found in the example, but must be added. Otherwise, QWIP will think that your publisher is NOT thread-safe, even if you have done multi-thread processing.

With this class, it is easy to use. You only need:

Create Application
1 Def Create_publisher ():
2 # Return publisher (rootdirectory (),
3 # Display_exceptions = 'plain ')
4 Return Threadedpublisher (rootdirectory ())
5
6 Import Traceback
7 From Quixote Import Get_wsgi_app
8
9 Try :
10 Pub = Create_publisher ()
11 Application = Get_wsgi_app ()
12 Except Typeerror, E:
13 Pass


Note that the object name "application = get_wsgi_app ()" must be "application", or "mod_wsgi" cannot find anything that can be called.

5. With the connection script, you only need to configure mod_wsgi. 1 Wsgiscriptalias/test D:/workplace/Alex/testquixote/wsgi. py
2 < Directory D:/workplace/Alex/testquixote />
3 Wsgiapplicationgroup % {Global}
4 Order deny, allow
5 Allow from all
6 </ Directory >

I have configured a directory here, and the rest can be divided into three

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.