Configure multiple Django projects on Apache

Source: Internet
Author: User

My environment is win7+python2.7.8+django1.6.4+apache2.2.

Don't say much nonsense, go straight to the point:

Download the corresponding version of mod_wsgi.so

The first step: Add mod_wsgi.so (remember the corresponding version) to the bottom of apache2.2\modules.

Open httpd.conf

Step Two: Add Module,loadmodule wsgi_module modules/mod_wsgi.so

Step three: Take the comment and find the loadmodule vhost_alias_module modules/mod_vhost_alias.so Delete the comment.

Fourth step: Look directly at the code!

Listen 8001 #第一个项目的监听端口NameVirtualHost *:8001 #名字而已 <virtualhost *:8001> documentroot "F:/workspaces_python/inv Estigatesystem "#项目根目录路径 wsgiscriptalias/" f:/workspaces_python/investigatesystem/investigatesystem/wsgi.py "# Path to project Wsgi file <directory "F:/workspaces_python/investigatesystem" > #配置目录的权限?       Which Warrior knows, please tell me, thank you. Order Deny,allow allow from all </Directory> alias/static "F:/workspaces_python/investigatesystem/stat        IC "#配置项目的静态文件路径 <directory" f:/workspaces_python/investigatesystem/static "> #同上? Options Indexes followsymlinks Order allow,deny allow from all </directory></virtualhost>li Sten 8002 #第二个项目的监听端口, in addition to the listening port other configuration basically the same namevirtualhost *:8002<virtualhost *:8002> documentroot "F:/workspaces_ Python/hospitalservice "Wsgiscriptalias/" f:/workspaces_python/hospitalservice/hospitalservice/wsgi.py "<   Directory "F:/workspaces_python/hospitalservice" > Order deny,allow    Allow from all </Directory> alias/static "F:/workspaces_python/hospitalservice/static" <directory         "F:/workspaces_python/hospitalservice/static" > Options Indexes followsymlinks Order Allow,deny Allow from all </Directory></VirtualHost>

Fifth Step: Modify the original wsgi.py file in the Django project to see the code:

1 ImportOS2 ImportSYS3 4Sys.path.append ('F:/workspaces_python/investigatesystem') #这里的路径改成项目对应的路径就好了5 6os.environ['Django_settings_module'] ='investigatesystem.settings' #这里的settings, you know! 7os.environ['Python_egg_cache'] ='/ tmp'8 9 ImportDjango.core.handlers.wsgiTenapplication = Django.core.handlers.wsgi.WSGIHandler ()

OK, here is basically configured to complete, open Apache run it.

Configure multiple Django projects on Apache

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.