httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Bell <d...@plainblack.com>
Subject Re: [users@httpd] Running php scripts outside of document root
Date Sun, 24 May 2009 05:45:48 GMT
On May 24, 2009, at 12:31 AM, Lyle Wincentsen wrote:

> In short, I am trying to set up my document root to be /var/www/htdocs
> and I want my php scripts to run in /var/www/cgi-bin.

Why? You can run PHP scripts in the same directory as your htdocs as  
you want.

> For some reason
> I am getting "500 internal server error" when I try to run a script
> (called phpauth.php) in that directory. If I try to run the same
> script in the document root, it works fine but I don't want to do
> that.
>
> Here are the relevant lines of the error log:
>
> [Sat May 23 22:19:02 2009] [error] [client {mylaptop.ip.address}]
> (8)Exec format error: exec of '/var/www/cgi-bin/phpauth.php' failed,
> referer: http://{myserver.ip.address}
> [Sat May 23 22:19:02 2009] [error] [client {mylaptop.ip.address}]
> Premature end of script headers: phpauth.php, referer:
> http://{myserver.ip.address}

Exec format error means your #! line is incorrect. Since you're using  
PHP, you're probably not using CGI (which requires the #! line)

> #	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
> 	ScriptAlias /cgi-bin/ /var/www/cgi-bin/

Here's the issue. It should be "Alias" not "ScriptAlias". If you  
intend on also running CGI scripts from this directory, add  
"AddHandler cgi-script .cgi" to the <Directory /var/www/cgi-bin> block.

Make sure to enable PHP for that directory as well: AddHandler  
application/x-httpd-php .php

Doug Bell -- Senior Developer, Plain Black Corp.
[ http://plainblack.com ]




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message