在apache服务器上部署两个django项目总结

4 篇文章 0 订阅
0 篇文章 0 订阅

环境说明:

Windows server2003(64) + Apache2.2 + python2.7.11 + django1.11

 

项目路径说明:

两个django项目分别为aaabbb,与apache在同一个目录Apache Software Foundation,即在Apache Software Foundation文件夹下有Apache2.2  aaa  bbb 三个文件夹,

 

单个django项目在apache的部署参考这篇博客:http://www.cnblogs.com/fnng/p/4119712.html

 

端口监听在http.conf文件中设置为:

Listen 80

 

http.conf中设置Servername127.0.0.1


正文:

 

1.首先,下载pythonweb服务器网关接口wsgi,将其命名为mod_wsgi.so,并添加到Apache2.2modules目录下

 

2.Apache2.2conf目录下的httpd.conf文件中加入以下代码以让apache加载wsgi模块:

LoadModule wsgi_module modules/mod_wsgi.so

 

3. httpd.conf 文件中加入以下代码说明python 环境路径:

WSGIPythonPath "C:/Python27/Lib;C:/Python27/Lib/site-packages;C:/Python27/DLLs"

WSGIPythonHome "C:/Python27"

 

4.apache在启动时能加载虚拟主机模块。打开httpd.conf 文件,找到一下两行代码,将前面的#删掉:

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

#Include conf/extra/httpd-vhosts.conf  

 

5. httpd.conf 中添加我们django项目的目录,到aaa 和bbb所在层级就行了:

 

<Directory "D:/Program Files (x86)/Apache Software Foundation">

    #

    # Possible values for the Options directive are "None", "All",

 # or any combination of:

    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

    #

    # Note that "MultiViews" must be named *explicitly* --- "Options All"

    # doesn't give it to you.

    #

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/2.2/mod/core.html#options

    # for more information.

    #

    Options Indexes FollowSymLinks

 

    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #

    AllowOverride None

 

    #

    # Controls who can get stuff from this server.

    #

    Order allow,deny

    Allow from all

 

</Directory>

 

6.<IfModule alias_module>标签内添加 :

ScriptAlias /cgi-bin/D:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin

 

7.修改cgi-bin目录为:

<Directory "D:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">

    AllowOverride None

    Options None

    Order allow,deny

    Allow from all

</Directory>

 

 

8.接下来,保存并关闭以上我们修改的httpd.conf文件,打开 conf文件夹下的extra文件,找到

httpd-vhosts.conf 文件并打开做修改:

 

<VirtualHost *:80>  

  ServerName xxx.com

ServerAlias www.xxx.com

  WSGIScriptAlias / "D:/Program Files (x86)/Apache Software Foundation/aaa/aaa/wsgi.py"

 

  Alias /static "D:/Program Files (x86)/Apache Software Foundation/aaa/mysite1/static"  

  <Directory "D:/Program Files (x86)/Apache Software Foundation/aaa/mysite1/static">     

    Allow from all   

  </Directory>     

  

  DocumentRoot "D:/Program Files (x86)/Apache Software Foundation/aaa"  

  <Directory "D:/Program Files (x86)/Apache Software Foundation/aaa">  

        Options Indexes FollowSymLinks  

        AllowOverride None  

  </Directory>  

</virtualHost>  

  

 

<VirtualHost *:80>  

  ServerName yyy.com

  

  ServerAlias www.yyy.com

  WSGIScriptAlias / "D:/Program Files (x86)/Apache Software Foundation/bbb/bbb/wsgi.py"

    

  Alias /static "D:/Program Files (x86)/Apache Software Foundation/bbb/mysite2/static"  

  <Directory "D:/Program Files (x86)/Apache Software Foundation/bbb/mysite2/static">     

    Allow from all

  </Directory>     

  

  DocumentRoot "D:/Program Files (x86)/Apache Software Foundation/bbb"  

  <Directory "D:/Program Files (x86)/Apache Software Foundation/bbb">  

        Options Indexes FollowSymLinks  

        AllowOverride None  

  </Directory>  

</virtualHost>  

 

9.最后,打开两个项目的wsgi.py文件,把我们的项目加进去即可;

  import sys    

  sys.path.append('D:/Program Files (x86)/Apache Software Foundation/aaa) 

 

10.重启apache即可 




  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值