三、MySQLdb 安装 yum install python-devel mysql-devel, easy_install-2.7 MySQL-python 如果不行 下载安装 下载mysql-python:http:///projects/mysql-python/ wget http:///projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz tar zxvf MySQL-python-1.2.3.tar.gz cd MySQL-python-1.2.3 python2.7 setup.py install 四、测试站点的搭建: 测试下各个模块 cd /var/www/html/ django-admin.py startproject hello python manage.py startapp blog vi blog/models.py ############################################### from django.db import models class Category(models.Model): name = models.CharField(max_length=32) def __unicode__(self): return self.name class Article(models.Model): title = models.CharField(max_length=64) published_at = models.DateTimeField('date published') content = models.TextField() category = models.ForeignKey(Category) def __unicode__(self): return self.title ################################################ python manage.py sql blog mkdir static media <VirtualHost *:80> ServerName www.hello.com #ServerAlias www.hello.com ErrorLog logs/www.hello.com.error_log CustomLog logs/www.hello.com.access_log common WSGIScriptAlias / /var/www/html/hello/hello/wsgi.py <Directory "/var/www/html/hello"> Order deny,allow Allow from all </Directory> WSGIProcessGroup www.hello.com WSGIDaemonProcess www.hello.com Alias /media/ /var/www/html/hello/media/ Alias /adminmedia/ /usr/local/lib/python2.7/site-packages/django/contrib/admin/media/ Alias /static /var/www/html/hello/static <Directory "/var/www/html/hello/static"> Order deny,allow Allow from all </Directory> Alias /media /var/www/html/www.hello.com/media <Directory "/var/www/html/hello/media"> Order deny,allow Allow from all </Directory> </VirtualHost> 如果报错: vim ImportError: No module named django.core.management #!/usr/local/lib/python2.7/site-packages/django/bin/django-admin.py |
|
来自: python_diango > 《centos5.8》