Re: Running php scripts outside of document root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux