上善若水,不浮不沉!
分类: Python/Ruby
2014-05-07 10:15:17
最近开始学习python&mysql&django,搭建环境的时候花了不少时间,把当时的操作记录下来,以作参考。都是一些简单的安装步骤,高手至此可以略过了~1、安装python,默认情况下需要用root账号,用这个方法可以绕过(但python只在当前用户下有效):tar -zvxf Python-2.7.1.tgzcd Python-2.7.1./configure --prefix=/home/denglu/python --enable-sharedmakemake installvi .bash_profile
PATH=$HOME/python/bin:$PATH:$HOME/binexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/denglu/python/lib
source .bash_profile
2、安装mysql
tar -zvxf mysql-5.0.51b.tar.gzcd mysql-5.0.51b./configure --prefix=$HOME/mysql --with-charset=gbk --enable-local-infile --with-unix-socket-path=$HOME/mysql/mysql.sock --with-mysqld-user=denglumakemake installcd ~/django_tools/mysql-5.0.51b/support-filescp my-medium.cnf ~/mysql/my.cnf注意my.cnf中的路径[client]socket = /home/denglu/mysql/mysql.sock[mysqld]socket = /home/denglu/mysql/mysql.sock其中跟denglu有关的部分在迁移时需要注意迁移后修改为正确的路径./bin/mysql_install_db --user=rootbin/mysqld_safe --user=root &bin/mysqladmin -u root password '123456'设置.bash_profilePATH=$HOME/python/bin:$HOME/mysql/bin:$PATH:$HOME/binexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/python/lib:$HOME/mysql/lib/mysql
3、安装djangotar -zvxf Django-1.2.3cd Django-1.2.3python setup.py installcd ~/python/lib/python2.7/site-packages/django/confvi global_settings.py修改为TIME_ZONE = 'CCF'LANGUAGE_CODE = 'zh-cn'DEFAULT_CHARSET = 'gbk'SERVER_EMAIL = 'denglu.hust@gmail.com'
4、网上说可以用如下方法安装mysql-python,但我看了下mysql-python的说明,居然还只支持到2.6,遂作罢,以后有需要的时候再添加吧。tar -zvxf ./MySQL-python-1.2.3.tar.gzcp -r MySQL-python-1.2.3 ~/pythonvi site.cfgthreadsafe = Falseregistry_key = SOFTWARE\MySQL AB\MySQL Server 5.0grep 'usr/' *dbapi20.pysetup.pytest_capabilities.pytest_MySQLdb_capabilities.pytest_MySQLdb_dbapi20.py把这些文件中的#!/usr/bin/env python去掉python setup.py buildpython setup.py installcd django-suite/python/lib/ln -s ~//mysql/lib/mysql/libmysqlclient.so.15.0.0 libmysqlclient.so.15ln -s ~//mysql/lib/mysql/libmysqlclient.so.15.0.0 libmysqlclient.soln -s ~//mysql/lib/mysql/libmysqlclient.so.15.0.0 libmysqlclient.so.15.0.0