Use Apache + mod_wsgi to deploy a webpy Application

Source: Internet
Author: User
The following steps passed the test in Apache-2.2.3 (RedHatEnterpriseLinux5.2, x86_64), mod_wsgi-2.0. Note: You can replace the appname with your own project name. You can use your own file name to replace

The following steps are performed in Apache-2.2.3 (REdHat Enterprise Linux 5.2, x86_64), tested in mod_wsgi-2.0. I have passed the test in Windows2003 + Apache-2.2.15 + mod_wsgi-3.0)

Note:

  • You can replace 'appname' with your own project name '.
  • You can replace 'Code. py' with your own file name '.
  • /Var/www/webpy-app is the directory path of the folder containing your code. py.
  • /Var/www/webpy-app/code. py is the complete path of your python file.

Steps:

  • Download and install mod_wsgi from its website:

Http://code.google.com/p/modwsgi/. It will install a '. so' module to your apache module folder, for example:

    /usr/lib64/httpd/modules/
  • In httpd. conf, configure Apache to load the mod_wsgi module and your project:

      LoadModule wsgi_module modules/mod_wsgi.so  WSGIScriptAlias /appname /var/www/webpy-app/code.py/  Alias /appname/static /var/www/webpy-app/static/  AddType text/html .py  
              Order deny,allow      Allow from all  
  • Demo file 'Code. py ':

      import web  urls = (      '/.*', 'hello',      )  class hello:      def GET(self):          return "Hello, world."  application = web.application(urls, globals()).wsgifunc()
  • Enter 'HTTP: // your_server_name/appname' in the address bar of your browser to verify whether it is available.

Note: mod_wsgi + sessions

If you need to use sessions in mod_wsgi, you can change your Code as follows:

app = web.application(urls, globals())curdir = os.path.dirname(__file__)session = web.session.Session(app, web.session.DiskStore(curdir + '/' + 'sessions'),)application = app.wsgifunc()
Mod_wsgi performance:

For more information about mod_wsgi performance, see the mod_wsgi wiki: http://code.google.com/p/modwsgi/wiki/PerfoRmAnceEstimates

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.