0

环境:

Red Hat Enterprise Linux Server release 6.4 
Apache/2.2.15 (Unix) mod_perl/2.0.4 Perl/v5.10.1
Perl v5.10.1 (*) built for x86_64-linux-thread-multi
64 bit Oracle client for 11.2
DBD::Oracle : Oracle Driver for DBI ; P/PY/PYTHIAN/DBD-Oracle-1.64.tar.gz : /usr/local/lib64/perl5/DBD/Oracle.pm : Installed: 1.64 
/home/oracle/app/oracle/product/11.2.0/client_1/lib/libclntsh.so.11.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped 
-rwxr-xr-x. 1 oracle oracle 48725761 Jun 10 17:41 /home/oracle/app/oracle/product/11.2.0/client_1/lib/libclntsh.so.11.1

启动.pl

use lib qw(/home/oracle/app/oracle/product/11.2.0/client_1/lib);
BEGIN {
    $ENV{ORACLE_HOME}     = '/home/oracle/app/oracle/product/11.2.0/client_1';
    $ENV{LD_LIBRARY_PATH} = '/home/oracle/app/oracle/product/11.2.0/client_1/lib';
    $ENV{ORACLE_SID}      = 'MARS';
}
print STDERR "\nORACLE_HOME = " . $ENV{'ORACLE_HOME'} . "\n";
print STDERR "\nLD_LIBRARY_PATH = " . $ENV{'LD_LIBRARY_PATH'} . "\n";

use mod_perl2;
use Apache::DBI ();
use DBI ();
use DBD::Oracle;

BEGIN { use Data::Dumper; print STDERR Dumper(\@INC); }
print STDERR "ModPerl2 Startup.pl\n";
foreach ( keys %ENV ) {
    print STDERR "$_\t$ENV{$_}\n";
}
1;

阿帕奇会议

PerlRequire /var/www/cgi-bin/startup.pl
SetEnv ORACLE_HOME "/home/oracle/app/oracle/product/11.2.0/client_1"
SetEnv LD_LIBRARY_PATH "/home/oracle/app/oracle/product/11.2.0/client_1/lib"

错误:

Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 200.\n at /var/www/cgi-bin/startup.pl line 17\nCompilation failed in require at /var/www/cgi-bin/startup.pl line 17.\nBEGIN failed--compilation aborted at /var/www/cgi-bin/startup.pl line 17.\nCompilation failed in require at (eval 2) line 1.\n

Startup.pl 从命令行运行时有效,但无法通过 Apache 加载

已经尝试过的事情

  • 在 Apache conf 中设置环境变量(如上所示)
  • 检查 oracle 库的文件权限
  • 从命令行打印环境变量并与从 Apache 运行时的输出进行比较(删除 DBD::Oracle 之后)
  • 确保所有 Perl、Apache、Oracle、DBD:Oracle 都适用于 64 位
  • 将 /home/oracle/app/oracle/product/11.2.0/client_1/lib 添加到 /etc/ld.so.conf 并运行 ldconf
4

4 回答 4

0

该错误来自 Apache 无法找到 Oracle 安装。将您的 Oracle $PATH 环境变量放在 bin/envvars 文件中,如下所示:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# envvars-std - default environment variables for apachectl
#
# This file is generated from envvars-std.in
#
ORACLE_HOME="/home/oracle/app/oracle/product/11.2.0/client_1"
LD_LIBRARY_PATH="/home/oracle/app/oracle/product/11.2.0/client_1/lib"

export LD_LIBRARY_PATH ORACLE_HOME
于 2013-11-13T14:35:50.637 回答
0

在 RHEL(5、6 和 7)上有相同的错误消息。这就是最终为我解决的问题:

echo $ORACLE_HOME/lib >> /etc/ld.so.conf
/sbin/ldconfig
service httpd stop; service httpd start
于 2015-04-22T09:31:01.373 回答
0

如错误消息所示,您DBD::Oracle是针对 11.1 构建的,它正在寻找一个专门命名/版本化的 .so 文件(“libclntsh.so.11.1”)。

但是,您的运行时配置为 11.2,正如您的路径所证明的那样,并且不提供该特定命名/版本化的 .so 文件。

DBD::Oracle为您首选的运行时配置重新构建并从那里开始。

于 2013-11-13T15:11:11.890 回答
0

这很可能是一个 selinux 问题。如果您的脚本在 shell 中运行良好但在 apache 中运行良好,请尝试禁用 selinux。

如果有帮助,您最好配置 selinux 而不是禁用它。

于 2014-06-10T14:20:39.510 回答