ubuntu10.10+django+apache2+(mod-python 或 wsgi)

陈着 posted @ Mar 12, 2011 04:22:44 PM in server , 4909 阅读

这几天一直在折腾django在apache上的部署,网上的资料鱼龙混杂,特将经验记录下来,希望能帮助更多的人。

mod-python:

1.安装apache,mod-python:

sudo apt-get install apache2 libapache2-mod-python

2.在/etc/apache2/available/目录下建立配置文件:mytest

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot /home/sarlmolapple/workspace/django-site/mytest
	<Directory "/home/sarlmolapple/workspace/django-site">
		Allow from all
		SetHandler python-program
    		PythonHandler django.core.handlers.modpython
    		SetEnv DJANGO_SETTINGS_MODULE mytest.settings
    		PythonDebug On
    		PythonPath "['/home/sarlmolapple/workspace/django-site', '/home/sarlmolapple/workspace/django-site/mytest', '/home/sarlmolapple/workspace/django-site/mytest/mysite'] + sys.path"
	</Directory>
</VirtualHost>

注:django项目为mytest, 路径为:/home/sarlmolapple/workspace/django-site/mytest,

‘/home/sarlmolapple/workspace/django-site/mytest/mysite’为mytest中的app所在路径

3.运行命令:

sudo a2ensite mytest
sudo /etc/init.d/apache2 reload

然后你在浏览器中输入http://localhost就可以看到你想要看到的页面了

WSGI:

1.安装apache,mod-python:

sudo apt-get install apache2 libapache2-wsgi-python

2.在/etc/apache2/available/目录下建立配置文件:mytest

<VirtualHost *:80>
    ServerName wsgi.mytest
    DocumentRoot /home/sarlmolapple/workspace/django-site/mytest
    <Directory /home/sarlmolapple/workspace/django-site/mytest>
        Order allow,deny
        Allow from all
	PythonPath "['/home/sarlmolapple/workspace/django-site', '/home/sarlmolapple/workspace/django-site/mytest', '/home/sarlmolapple/workspace/django-site/mytest/mysite'] + sys.path"
    </Directory>
    WSGIDaemonProcess wsgi.mytest processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup wsgi.mytest
    WSGIScriptAlias / /home/sarlmolapple/workspace/django-site/mytest/apache/django.wsgi
</VirtualHost>

3.在mytest目录下建立apache/django.wsgi

import os
import sys

sys.path.append('/home/sarlmolapple/workspace/django-site')
sys.path.append('/home/sarlmolapple/workspace/django-site/mytest')
sys.path.append('/home/sarlmolapple/workspace/django-site/mytest/mysite')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mytest.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

注: mytest路径为:/home/sarlmolapple/workspace/django-site/mytest,‘/home/sarlmolapple/workspace/django-site/mytest/mysite’为mytest中的app所在路径

4.运行命令:

sudo a2ensite mytest
sudo /etc/init.d/apache2 reload

同理,你在浏览器中输入http://localhost就可以看到你想要看到的页面了。

Avatar_small
Alexander Deamer 说:
Feb 18, 2019 04:07:52 PM

The formally found items have been herd for the individuals. The race of the bloggers and essay on time review is marked for the people. The truth is elevated for the major chunk of the facility and its image for the people.

Avatar_small
cleaning services 说:
Sep 17, 2019 09:56:54 PM

The neighborhood house cleansing services businesses charge in a different way; it mostly depends upon your needs. So, if you're doing “deep cleansing, ” they offer a group sum amount for the entire job, and if you're living inside a studio, they might charge a person from two hundred to three hundred AED that could go as much as 1, 500 AED for any 5-bedroom condo.

Avatar_small
freeze business rate 说:
Nov 15, 2019 12:50:25 AM

Technology will surely be the best thing with regards to preschool training; it may also be a situation of an excessive amount of a positive thing. Ideally, screen-based technology particularly should end up being but one of many methods associated with instruction for young children,

Avatar_small
mentholatum home 说:
Mar 24, 2020 07:31:58 PM

Many people define luxurious majorly when it comes to price but there's a lot more to luxury than simply how much money you invest. It is extremely hard in order to define luxurious homes within an exact method because this really is something comprised of several elements.

Avatar_small
I sell pittsburgh ho 说:
Mar 24, 2020 07:33:10 PM

If you're buying a house that was once inspected then you must have your personal inspection done to become protected because fully as you possibly can. If anyone lets you know that it's fine to make use of the prior home examination report they're wrong. You're not guarded well whatsoever. When Habitation Analysis does a house inspection the customer is able to get a good 18 30 days warranty for that fee associated with 12 several weeks.

Avatar_small
wanamassa reale stat 说:
Mar 24, 2020 07:34:20 PM

So you need to be successful real property investor? Nicely, you must have your goal setting techniques in collection. In order to achieve the greatest possibility of achieving your own goals you have to be setting WISE goals. Right now, not the actual Webster description of wise, but instead SMART being an acronym with regard to Specific, Measurable, Achievable, Realistic, as well as Timely.

Avatar_small
north bama real esta 说:
Mar 24, 2020 07:34:47 PM

Property is the actual legal phrase encompassing property with something mounted on the property like structures, particularly home. These tend to be immobile or even fixed qualities. It may be the common jargon utilized in several jurisdictions for example Australia, North america, United Empire and america.

Avatar_small
atlanta black busine 说:
Mar 24, 2020 07:35:16 PM

One supply of capital which businesses frequently overlook is actually Vendor Credit score. Without a powerful banking romantic relationship and credit rating dealing along with any financial institution as a small company looking for any traditional loan or perhaps a working business credit line can be very hard and irritating.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter