静态编译安装MySQLdb

原本,Python世界中有easy_install/pip等神兵利器来安装第三方包,但公司服务器没法链接外网,所以只能采用下载包手动安装的方式。为了尽量下降部署复杂度,省去xxx.so找不到的麻烦,咱们决定采用静态连接的方式来安装MySQLdb。python

安装MySQl

  1. 从官网下载源代码。
  2. CFLAGS=-fPIC ./configure --prefix=/home/neoli/usr/ --enable-static --disable-shared --with-charset=utf8 --with-extra-charsets=ascii,binary,latin1,gbk --with-collation=utf8_general_ci
    使用--enable-static --disable-shared,咱们只会编译MySQL的静态库
  3. make && make install

安装MySQLdb

  1. 从https://pypi.python.org/pypi/MySQL-python/下载最新的包。
  2. 修改site.cfg,设置
    static=True
    mysql_config = #你的安装路径
  3. python setup.py build
  4. python setup.py install
相关文章
相关标签/搜索