先写几个中文字, 主题无关,本来没必要迁的项目, 主要是被赶得只好换了服务器. 就多做了这么多的事.
Currently Bluehost doesnt support Django officially.
to support Django.
1. Using self-packaged python/Django.
Download and unzip Python in:
/home/zip/Django/Python-2.8.5
using ez_setup.py/pip to install flup/Django/MySQL-python …
2. Using existing Project: RACBDM. edit .htaccess
1 2 3 4 5 6 7 8 9 10 |
> cat .htaccess #AddHandler fastcgi-script .fcgi AddHandler fcgid-script .fcgi # For security reasons, Option followsymlinks cannot be overridden. #options +FollowSymLinks options +SymLinksIfOwnerMatch RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !(mysite.fcgi) RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L] |
3. prepare mysite.fcgi
1 2 3 4 5 6 7 8 9 10 11 12 |
> cat mysite.fcgi #!/home/zip/Django/Python-2.8.5/bin/python #coding:utf-8 import sys, os from os.path import abspath,dirname import sys sys.path.insert(0,"/home/zip/Django/Python-2.8.5") sys.path.insert(0,"/home/zip/www/RACBDM") os.environ['DJANGO_SETTINGS_MODULE'] = "RACBDM.settings" from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false") |
4. ensure the mysql related configuration: <RACBDM.settings>
1 2 3 4 5 6 7 8 9 10 11 |
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'testjob_365', # The following settings are not used with sqlite3: 'USER': 'testjob_365', 'PASSWORD': '456sZfscc.98', 'HOST': '', 'PORT': '', } } |
5. confirm the template_dirs setting:
1 2 3 |
TEMPLATE_DIRS = ( '/home/zip/www/RACBDM/templates9', ) |
6. While migrating, it’s a good practice to enable DEBUG mode:
1 |
DEBUG = True |
7. Mysql related:
1 2 3 4 5 |
#on old node: > mysqldump -u asmcanet_racbdm -p asmcanet_RACBDM >~/zip0/racbdm.sql #on new node: > mysql -u testjob_365 -D asmcanet_RACBDM -p <~/backup/racbdm.sql |
8. mention that the dump script will not take care the View create status, if you have tables/views. please double check.