Apache2.4 configuration Mod_wsgi, deploying Python applications __python

Source: Internet
Author: User

1. Download Mod_wsgi, Address: http://code.google.com/p/modwsgi/downloads/list

2. After the download is complete (I am under the mod_wsgi-3.4.tar.gz)

Tar zxvf mod_wsgi-3.4.tar.gz

./configure--with-apxs=/home/aaron/httpd/bin/apxs--with-python=/usr/bin/python

Make && make install

This step is done, HTTPD's modules directory should have mod_wsgi.so

3. Modify the httpd.conf file and add:

LoadModule wsgi_module modules/mod_wsgi.so

4. Add the following line to the httpd.conf file, either server scope or VirtualHost (original: The directive can is used at server scope but normal Ly is placed withinthe VirtualHost container for a particular site):

Wsgiscriptalia/myapp/home/aaron/httpd/python/wsgi-scripts/myapp.wsgi

Wsgiscriptalia's first parameter represents the path to be bound to the WSGI application, and the second parameter is the path to the file on the server when accessing the WSGI application (when setting this path, be careful to create a specific directory, do not use $home, etc., the user has access rights, Easy to be hack)

5. Specify the access permissions for this path:

<directory "/home/aaron/httpd/python/wsgi-scripts" >
Require all granted
</Directory>

Note: The above is the syntax for Apache 2.4, and the 2.2 (previous) Version syntax description can be found in: http://blog.csdn.net/kittaaron/article/details/8940545

6. Write one of the simplest WSGI programs named Myapp.wsgi (corresponding to the 4th step, the following code is directly copied from the Http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide) , put it under the/home/aaron/httpd/python/wsgi-scripts/,

	def application (environ, start_response): 		status = ' OK ' 		output = ' Hello world!

' 		response_headers = [(' Content-type ', ' Text/plain '),
(' Content-length ', str (output))] 		start_response (status, Response_headers) return 		[Output]

7. Restart httpd. should be able to access from Http://hostname:port/myapp and return to Hello World.






Reference: Http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide

Http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

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.