Apache:To Config The Vhost of Django Project

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.

Apache:To Config The Vhost of Django Project_第1张图片

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:

The windows WAMP version:

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)

Apache:To Config The Vhost of Django Project_第2张图片

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

Put it in the apache modules

Apache:To Config The Vhost of Django Project_第3张图片

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.

Apache:To Config The Vhost of Django Project_第4张图片

 

Apache_django.wsgi

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

Apache:To Config The Vhost of Django Project_第5张图片

 

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

Seems like that:

Apache:To Config The Vhost of Django Project_第6张图片

Let's check into it

Apache:To Config The Vhost of Django Project_第7张图片

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

Apache:To Config The Vhost of Django Project_第8张图片

Shit,what's happened?

Check in the log path No Error found

Apache:To Config The Vhost of Django Project_第9张图片

Check httpd.conf:

Add this:

Check www root:seems ok

Apache:To Config The Vhost of Django Project_第10张图片

OK,restart apache:

Near to success!

Apache:To Config The Vhost of Django Project_第11张图片

Check in the error log:

Apache:To Config The Vhost of Django Project_第12张图片

….No module…….orz….

Apache_django.wsgi line 3

Maybe there's something wrong with my WSGIPythonPath

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

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

Change it!

Restart apache service!

Apache:To Config The Vhost of Django Project_第13张图片

 

I give up…

Tomorrow will be ok

Time to sleep…

你可能感兴趣的:(project)