简体   繁体   English

导入 cx_Oracle 导致 Apache 服务器抛出内部服务器错误

[英]Importing cx_Oracle causes an Apache server to throw an internal server error

I'm trying to configure the cx_Oracle python module to work with an Apache server on RHL.我正在尝试将cx_Oracle python 模块配置为与 RHL 上的 Apache 服务器一起使用。

I installed the python module and the oracle client on my user account and after some configuration it worked fine (I had to set the LD_LIBRARY_PATH environment variable and create a sym link to libclntsh.so.12.1 ).我在我的用户帐户上安装了 python 模块和 oracle 客户端,经过一些配置后它工作正常(我必须设置LD_LIBRARY_PATH环境变量并创建一个指向libclntsh.so.12.1的符号链接)。

Now I wanted to use this module with an Apache server, but after importing it in one of my python scripts the server started throwing a 500 error.现在我想将此模块与 Apache 服务器一起使用,但是在我的一个 python 脚本中导入它后,服务器开始抛出 500 错误。 The only things I changed in the configuration was setting $LD_LIBRARY_PATH and $ORACLE_HOME as global variables just to be sure and setting the $PYTHON_EGG_CACHE to /tmp so there aren't any permission issues.我在配置中更改的唯一内容是将$LD_LIBRARY_PATH$ORACLE_HOME设置为全局变量以确保并将$PYTHON_EGG_CACHE设置为/tmp以便没有任何权限问题。

After that the server was still not working so I wanted to see what the error is.之后服务器仍然无法工作,所以我想看看错误是什么。 I run these commands:我运行这些命令:

sudo su
sudo -u apache python
>>> import cx_Oracle

This worked fine and now I'm really confused about why it's not working on the server.这工作得很好,现在我真的很困惑为什么它不能在服务器上工作。 Is there something I'm misunderstanding or doing wrong?我有什么误解或做错了吗?

EDIT: Just to clarify, the Apache server is on the same machine as my user account.编辑:澄清一下,Apache 服务器与我的用户帐户在同一台​​机器上。

Setting the library search path environment variables is often the weak point.设置库搜索路径环境变量通常是弱点。 How and where you set them depends on your Apache version.设置它们的方式和位置取决于您的 Apache 版本。 In particular sometimes you use shell syntax (and referenced variables get expanded), other times you need absolute paths.特别是有时您使用 shell 语法(并且引用的变量被扩展),其他时候您需要绝对路径。

If you have installed Oracle Instant Client (and have no other Oracle software) then just use ldconfig as described in the Instant Client installation instructions (and don't set LD_LIBRARY_PATH or ORACLE_HOME).如果您已经安装了 Oracle Instant Client(并且没有其他 Oracle 软件),那么只需按照Instant Client 安装说明中的说明使用ldconfig (并且不要设置 LD_LIBRARY_PATH 或 ORACLE_HOME)。

Otherwise or RHL you probably want to edit /etc/sysconfig/httpd and add something like:否则或 RHL,您可能想要编辑/etc/sysconfig/httpd并添加如下内容:

export LD_LIBRARY_PATH=/home/cjones/instantclient 

or或者

LD_LIBRARY_PATH=/home/cjones/instantclient

But your boot scripts may be different, so check what you need.但是您的启动脚本可能会有所不同,因此请检查您需要什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM