?
Solved

Running PHP as a CGI under apache - problems.

Posted on 2005-03-09
8
Medium Priority
?
571 Views
Last Modified: 2013-11-18
Hopefully this is thebest place to ask..

I'm trying to run PHP as a cgi under apache, I have takent he following steps:

create a softlink from /usr/bin/php to the user cgi-bin dir.

in .htaccess in the htdocs dir, i put:
Action php-suid /cgi-bin/php
AddHandler php-suid .sphp

Then I create a very simple php file in the same htdocs dir, just echos a single line.   Im sure it executes properly since I can run "php test.sphp" and it works fine.

So now, when I try to browse here, I get http error 500 and in error_log i get:
"....Premature end of script headers: php"


One note - cgi's are being run suexec, (which is why I am going through this all to begin with).

From what I've read, this should be working.. Any ideas anyone?
All help appreciated.
0
Comment
Question by:jbwasted
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13499302
> cgi's are being run suexec,
does the su'ed user have read permissions on the directory and the file?

what does
  php -f your.php && echo ok
print?

try to copy php to cgi-bin instead symlinking
0
 

Author Comment

by:jbwasted
ID: 13499448
Yep su'd user is the owner of directory and file.

pf -f... does :
Content-type: text/html

test!
ok


Okay, I tried copying php instead of linking, and that is weird, its like its trying to interpret the php binary.

No http errors wtih that, but php gives me this error:

Warning: Unexpected character in input: '' (ASCII=8) state=1 in /var/www/html/user_cgi/cmstest/php on line 942

Warning: Unexpected character in input: '' (ASCII=7) state=1 in /var/www/html/user_cgi/cmstest/php on line 942

Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /var/www/html/user_cgi/cmstest/php on line 942

Thanks
0
 

Author Comment

by:jbwasted
ID: 13499452
edit- Not only is the user the owner, but they have proper access.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 13499515
AFAIK apache's suEXEC does not allow symlinks, also the owner of the file must be the same as the su'd user.
I'm not shure where seEXEC searches the binary, think that's your problem.
0
 

Author Comment

by:jbwasted
ID: 13499921
Hmmmm Looks like a bug in php. http://bugs.php.net/bug.php?id=7641

I guess I'll compile a new version and see if that works.
0
 
LVL 1

Expert Comment

by:pmrussell892
ID: 13582816
What file editopr did you use to write the php script?

Looks like a symbol that word on microsoft windows would put into a file. Did you use some word editor to write the script?
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13816864
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question