# PHP4 CGI on Apache 2.2 causes permission problem [SOLVED]

## paulodeon

Hi,

I'm a gentoo noob, and I've managed so far to get a working webserver without any help by much trial and error. I've had a requirement to do some php4 development so I've had to install php4 alongside php5 on the webserver.

I followed the guide at http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml (Alternative 2 with per vhost config of domain) but I cant get php4 to work at all...

When I try to access a php4 file such as phpinfo.php i get "403 Forbidden You don't have permission to access /php4-cgi/phpinfo.php on this server." Then in the error_log file I get [error] [client xx.xx.xx.xx] client denied by server configuration: /usr/lib/php4/bin/php-cgi

I've searched high and low on the internet and forums to no avail. Here are my config files if it helps:

/etc/apache2/modules.d/php4-cgi.conf

<IfDefine PHP4CGI>

        ScriptAlias /php4-cgi /usr/lib/php4/bin/php-cgi

        Action php4-cgi /php4-cgi

        AddHandler php4-cgi .php4 .php3 .phtml

</IFDefine>

/etc/apache2/vhosts.d/02_ctd_vhost.conf

<VirtualHost 192.168.1.66:80>

  ServerName ctd.tinderfields.net

  DocumentRoot /var/www/localhost/ctd.tinderfields.net

  DirectoryIndex index.html index.htm index.php

  php_admin_value include_path ".:/var/www/localhost/ctd.tinderfields.net"

  <Directory /var/www/localhost/ctd.tinderfields.net>

    AddHandler php4-cgi .php

    Options FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

  </Directory>

</VirtualHost>

I am running hardened gentoo with apache 2.2, if that makes any difference

Thanks for your time...Last edited by paulodeon on Sat Aug 25, 2007 8:29 am; edited 1 time in total

----------

## rman77

I had this problem along time ago on a red hat box, the problem is the apache user doesn't have permission to access /usr/lib/php4/bin/php-cgi.

This can be caused by number of things such as suexec, selinux ect. (you mentioned you were running hardened gentoo are you using any of those?)

**EDIT**

Actually... on second though, it might be a simple problem... when executing php through cgi the script must be executable by the apache user, so if you haven't already, see if chmod +x myscript.php works.

----------

## paulodeon

Thanks for the suggestions, I think you might be on to the right thing there.

I'll check it as soon as I get into the office tomorrow.

Cheers

----------

## paulodeon

I set the user and group of php-cgi to apache.apache, did u+x and g+x on the php file and disabled Suexec from the the apache startup file but still no joy.

The only thing I can think that it could be now is that php4 isnt compatible with apache 2.2

I had to force install apache 2.2 because by default hardened comes with 2.0, maybe php4 isnt compiling correctly.

Whats really annoying is that I cant get any more information from the logs

----------

## paulodeon

Found the cause of the problem on the following gentoo forum post https://forums.gentoo.org/viewtopic-t-412827-highlight-php4cgi.html

I basically changed the file /etc/apache2/modules.d/php4-cgi.conf to:

IfDefine PHP4CGI>

        ScriptAlias /php4-cgi /usr/lib/php4/bin/php-cgi

        Action php4-cgi /php4-cgi

        AddHandler php4-cgi .php4 .php3 .phtml

        <Directory /usr/lib/php4/bin>

                AllowOverride None

                Options None

                Order allow,deny

                Allow from all

        </Directory>

</IFDefine>

I had actually tried this before but I had used   <Directory /php4-cgi> instead of <Directory /usr/lib/php4/bin>

thanks rman   :Very Happy: 

----------

## tecknojunky

 *paulodeon wrote:*   

> 
> 
>         <Directory /usr/lib/php4/bin>
> 
>                 AllowOverride None
> ...

 

Thanks!   :Very Happy:   For once, the forum gave me the exact solution right away thanks to you.

----------

## bfx81

...same problem with php5-cgi

...same solution (well obviously adjusting the php5 bin path!)

----------

