码迷,mamicode.com
首页 > 其他好文 > 详细

Apache:To Config The Vhost of Django Project

时间:2014-09-25 02:39:28      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   strong   for   

It is not a good idea to use dev server in Production Environment.

Apache or Nginx are good choice.Both of them are of great used as the web server.

I‘m trying to deploy in apache.

 

The File Structre:

If you‘ve read djangoproject‘s documentation,you will find that my project‘s file structure is a bit different from what the documentation show(via)

Both are ok.

bubuko.com,布布扣

Imagine that you have the apache installed.And now ,lets do it 1 by 1.

Step 1:Edit The httpd.conf

/path/to/the/apache/conf/thhpd.conf

Add a new line just at the end of the file.It seems to be looked like this:

bubuko.com,布布扣

The windows WAMP version:

bubuko.com,布布扣

You need do nothing but just add this line in httpd.conf.I suggest you to do like that,because to config your apache_django project in a included file will not break the  protect the integrity of httpd.conf.

 

Step 2:Add mod_wsgi in to the modules path of apache:

While the Python gets a x86 and x64 version, and it is the same with the mod_wsgi

First, download the right version of mod_wsgi.For example,I have Python2.7.x.amd64 and Apache 2.4.x installed in my pc(x64).So, I need to use (via)

bubuko.com,布布扣

Uzip the package and you will get a mod_wsgi.so.

Put it in the apache modules

bubuko.com,布布扣

Step 3:Edit the apache_django.conf and apache_django.wsgi

Apache_django.conf

Ps.in this config file,I load the mod_wsgi module,config the vietual python env

Listen the 8000 port which is used in my django project and in the <VirtualHost 127.0.0.1:8000> ….. </VirtualHost> I config something of my project.

bubuko.com,布布扣

 

Apache_django.wsgi

In this file ,I add the project into the python path so that django driver can get the application

bubuko.com,布布扣

 

Step 4:cp the project files in to the www:

Seems like that:

bubuko.com,布布扣

Let‘s check into it

bubuko.com,布布扣

After all above,restart apache server.type http://127.0.0.1:8000

bubuko.com,布布扣

Shit,what‘s happened?

Check in the log path No Error found

bubuko.com,布布扣

Check httpd.conf:

bubuko.com,布布扣

Add this:

bubuko.com,布布扣

Check www root:seems ok

bubuko.com,布布扣

OK,restart apache:

Near to success!

bubuko.com,布布扣

Check in the error log:

bubuko.com,布布扣

….No module…….orz….

Apache_django.wsgi line 3

bubuko.com,布布扣

Maybe there‘s something wrong with my WSGIPythonPath

bubuko.com,布布扣

Let‘s have a look at where the virtual env‘s site-packages are:

bubuko.com,布布扣

……………………………………..orz…

Change it!

bubuko.com,布布扣

Restart apache service! bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

 

I give up…

Tomorrow will be ok

Time to sleep…

Apache:To Config The Vhost of Django Project

标签:style   blog   http   color   io   os   ar   strong   for   

原文地址:http://www.cnblogs.com/MrWho/p/3991850.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!