一、安装python
1、Linux下安装(其他系统请自行前往官网安装)
--- 安装依赖包
# cd /usr/local
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y
# wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
# tar -xzvf Python-2.7.12.tgz
# cd Python-2.7.12
# ./configure --prefix=/usr/local/Python2.7.12 --enable-shared -enable-unicode=ucs4
# make
# make install
# python -V
2、python解释器指向python2.7.12
# which python
# cd /usr/bin
# rm python
# ln -s /usr/local/Python2.7.12/bin/python python
# python -V --执行报错
3、解决python -V执行报错
# cd /etc/ld.so.conf.d/
# echo "/usr/local/Python2.7.12/lib" > python2.7.conf
# ldconfig
# python -V
4、由于yum使用了原来python2.6的一些脚本,需要将yum重新导向原来的python2.6解释器才可以使用
# which yum
# vi /usr/bin/yum
----修改第一行路径为: #!/usr/bin/python2.6
二、安装mysql
1、 查看是否安装了mysql数据库:rpm -qa | grep mysql
2、 强制卸载mysql数据库:rpm -e nodeps mysql
3、 通过命令查看yum上提供的数据库可下载版本:yum list | grep mysql
4、安装数据库: yum -y install mysql-server mysql-devel
5、启动数据库: service mysqld start
6、停止数据库 service mysqld stop
8、查看是否是开机启动(若2~5都是on则表明是开机启动):
chkconfig --list | grep mysqld
9、若2~5都是off则用以下命令设置: chkconfig mysqld on
10、 chkconfig --list | grep mysqld
11、启动mysql: service mysqld start
三、安装pip
1、安装setuptools软件包:
(1)下载setuptools包
# wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2)解压setuptools包
# tar zxvf setuptools-2.0.tar.gz
# cd setuptools-2.0
(3)编译setuptools
# python setup.py build
(4)开始执行setuptools安装
# python setup.py install
2、pip下载:
# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
pip安装:
# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
如果pip安装之后还是检测不到,那么可能是python没有加入环境变量的原因,
将/usr/local/python2.7.12/bin/的pip 拷贝到 /usr/bin/
四、安装mysql-python和django
1、安装mysql-python
pip install mysql-python
2.安装django
pip install Django==1.8.2