简体   繁体   中英

Error running perlbrew script though apache+suexec

We have a server running Centos 5.11, Apache 2.2 and default perl. Running scripts through suexec is working "just fine", but I have installed perlbrew so that I can install a load of extra modules without interferring with it.

I have created a simple perl script to test:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "perl: ". $^X . "\n";

When run through apache+suexec, it outputs, as expected:

Hello, world! perl: /usr/bin/perl

But, when I change the shebang line to:

#!/root/perl5/perlbrew/perls/perl-5.22.1/bin/perl

and run the same way, I get an internal server error, and the apache error log shows:

suexec failure: could not open log file
fopen: Permission denied
Premature end of script headers: test.cgi

but running at the command line is fine:

# ./test.cgi 
Content-type: text/html
Hello, world!
perl: /root/perl5/perlbrew/perls/perl-5.22.1/bin/perl

I've tried all sorts of things. I did wonder if it's a "PATH" issue, but apache docs say "On 2.2, the PATH environment variable cannot be set using Setenv."

The suexec errors usually seem to be caused by dos/unix encoding - but that's not an issue here.

Might it be an issue with the way I've installed perlbrew? Should it be as a different user (as apache)? different location (under /var/www)?

Any other suggestions welcomed!

Solved it - your nudge got me in the right direction.

This was a clue:

# suexec -V
 -D AP_DOC_ROOT="/var/www"
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER="apache"
 -D AP_LOG_EXEC="/var/log/httpd/suexec.log"
 -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D AP_UID_MIN=500
 -D AP_USERDIR_SUFFIX="public_html"

I reinstalled perlbrew, changing the root:

# export PERLBREW_ROOT=/usr/local/bin/perlbrew
# perlbrew install perl-5.22.1

then changed the script to:

#!/usr/local/bin/perlbrew/perls/perl-5.22.1/bin/perl

and bingo:

Hello, world! path: /usr/local/bin/perlbrew/perls/perl-5.22.1/bin/perl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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