资讯专栏INFORMATION COLUMN

django+centos+cx_Oracle开发环境搭建

godlong_X / 2681人阅读

摘要:设置固定重启配置文件使之生效安装安装略安装文件如下然后让新环境生效安装如果默认源被墙壁打开文件在其中添加然后重启网卡使用命令数据库数据库添加以下内容到然后让新环境

Linux设置固定IP

vi /etc/sysconfig/network-scripts/ifcfg-eth0

</>复制代码

  1. DEVICE=eth0
  2. BOOTPROTO=static
  3. IPADDR=192.168.0.116
  4. NETMASK=255.255.0.0
  5. GATEWAY=192.168.0.1
  6. ONBOOT=yes
  7. TYPE=Ethernet
重启配置文件使之生效

/etc/init.d/network restart

pip 安装

tar -xzvf pip-1.5.4.tar.gz
pip install xxx -i http://pypi.douban.com/simple

django 安装

Oracle client 安装

./centos_cx_Oracle.sh 文件如下:

</>复制代码

  1. #!/bin/bash
  2. # INSTALL ORACLE INSTANT CLIENT #
  3. #################################
  4. # NOTE: Oracle requires at least 1176 MB of swap (or something around there).
  5. # If you are using CentOS in a VMWare VM, there"s a good chance that you don"t have enough by default.
  6. # If this describes you and you need to add more swap, see the
  7. # "Adding a Swap File to a CentOS System" section, here:
  8. # http://www.techotopia.com/index.php/Adding_and_Managing_CentOS_Swap_Space
  9. # Install basic dependencies
  10. sudo yum -y install libaio bc flex
  11. echo "Now go get some the following two RPMs ..."
  12. echo "- basic: oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm"
  13. echo "- SDK/devel: oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm"
  14. echo "... from this URL: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html"
  15. echo "WARNING: It"s pretty annoying, they make you sign up for an Oracle account, etc."
  16. echo "I will assume you have put these two files are into ~/Downloads"
  17. echo "Press any key once you"re ready" && read -n 1 -s
  18. sudo rpm -ivh ~/Downloads/oracle-instantclient11.2-basic-*
  19. sudo rpm -ivh ~/Downloads/oracle-instantclient11.2-devel-*
  20. sudo rpm -ivh ~/Downloads/oracle-instantclient11.2-sqlplus-*
  21. # SET ENVIRONMENT VARIABLES #
  22. #############################
  23. # Source for this section: http://cx-oracle.sourceforge.net/BUILD.txt
  24. # (SIDENOTE: I had to alter it by doing some digging around for where the Oracle RPMs really installed to;
  25. # if you ever need to do this, do a command like this:
  26. # rpm -qlp )
  27. echo "# Convoluted undocumented Oracle bullshit." >> $HOME/.bashrc
  28. echo "export ORACLE_VERSION="11.2"" >> $HOME/.bashrc
  29. echo "export ORACLE_HOME="/usr/lib/oracle/$ORACLE_VERSION/client64/"" >> $HOME/.bashrc
  30. echo "export PATH=$PATH:"$ORACLE_HOME/bin"" >> $HOME/.bashrc
  31. echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$ORACLE_HOME/lib"" >> $HOME/.bashrc
  32. . $HOME/.bashrc
  33. # INSTALL cx_Oracle #
  34. #####################
  35. pip install cx_Oracle

然后让新环境生效 source ~/.bash_profile

cx_Oracle 安装

error: command "gcc" failed with exit status 1
yum -y install gcc-* libxml2-devel python-devel mysql-devel

如果centos默认源被墙壁

打开文件/etc/resolv.conf在其中添加:
nameserver 8.8.8.8
然后重启网卡:使用命令: service network restart
/usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora

</>复制代码

  1. x =
  2. (DESCRIPTION =
  3. (ADDRESS_LIST =
  4. (ADDRESS = (PROTOCOL = TCP)(HOST = 数据库IP)(PORT = 1521))
  5. )
  6. (CONNECT_DATA =
  7. (SID = 数据库)
  8. )
  9. )

添加以下内容到 /etc/profile

</>复制代码

  1. export ORACLE_HOME=/usr/lib/oracle/11.2/client64
  2. export TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/ admin
  3. export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  4. export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/lib
  5. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib;

然后让新环境生效 source /etc/profile

然后再安装PIL库

用pil产生验证码出现:ImportError: The _imagingft C module is not installed
这个是由于PIL没有编译freetype导致的

需要先安装jpeg库

</>复制代码

  1. wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
  2. tar -zxvf jpegsrc.v7.tar.gz
  3. cd jpeg-7
  4. CC="gcc -arch x86_64"
  5. ./configure --enable-shared --enable-static
  6. make
  7. make install
然后再安装PIL库

让PIL支持freetype的方法
1、安装freetype开发库
yum install freetype-devel

2、下载源代码
http://effbot.org/downloads/Imaging-1.1.7.tar.gz

3、修改setup.py文件

</>复制代码

  1. JPEG_ROOT = libinclude("/usr/local")
  2. FREETYPE_ROOT = "/usr/lib64","/usr/include/freetype2/freetype"

4、查看支持项
python setup.py build_ext -i
--- FREETYPE2 support available 注意这一项

5、编译安装
python setup.py install
若上面的设置都失败,则只能拿出下面的杀手锏:

</>复制代码

  1. sudo apt-get build-dep python-imaging
  2. sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
  3. pip install -U PIL

当现下面的提示时,则说明安装成功了:

--------------------------------------------------------------------PIL 1.1.7 SETUP SUMMARY--------------------------------------------------------------------version 1.1.7platform linux2 2.7.3 (default, Apr 10 2012, 22:21:37) [GCC 4.6.3]----------------------------------------------------------------------- TKINTER support available--- JPEG support available--- ZLIB (PNG/ZIP) support available--- FREETYPE2 support available*** LITTLECMS support not available--------------------------------------------------------------------

DjangoCaptcha 安装

用于验证码生成

xlwt 安装

pip install xlwt

unipath 安装

pip install unipath

ORA-21561: OID generation failed

添加 127.0.0.1 主机名称 到 /etc/hosts

关闭防火墙

iptables -F

django 测试

settings文件修改:

</>复制代码

  1. DEBUG = True
  2. INTERNAL_IPS = ("127.0.0.1", "192.168.1.100")
cron服务

</>复制代码

  1. /sbin/service crond start
  2. /sbin/service crond stop
  3. /sbin/service crond restart
  4. /sbin/service crond reload
web服务器时间同步

ntpdate time.nist.gov

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/17359.html

相关文章

  • django+centos+cx_Oracle开发环境搭建

    摘要:设置固定重启配置文件使之生效安装安装略安装文件如下然后让新环境生效安装如果默认源被墙壁打开文件在其中添加然后重启网卡使用命令数据库数据库添加以下内容到然后让新环境 Linux设置固定IP vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.0.116 NE...

    libin19890520 评论0 收藏0

发表评论

0条评论

godlong_X

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<