Gentoo Forums
Gentoo Forums
Quick Search: in
PHP4 CGI on Apache 2.2 causes permission problem [SOLVED]
View unanswered posts
View posts from last 24 hours

rackathon
 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
paulodeon
n00b
n00b


Joined: 24 Aug 2007
Posts: 4

PostPosted: Fri Aug 24, 2007 1:16 pm    Post subject: PHP4 CGI on Apache 2.2 causes permission problem [SOLVED] Reply with quote

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 3:29 am; edited 1 time in total
Back to top
View user's profile Send private message
rman77
n00b
n00b


Joined: 18 Sep 2004
Posts: 50
Location: USA

PostPosted: Fri Aug 24, 2007 1:39 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
paulodeon
n00b
n00b


Joined: 24 Aug 2007
Posts: 4

PostPosted: Fri Aug 24, 2007 3:46 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
paulodeon
n00b
n00b


Joined: 24 Aug 2007
Posts: 4

PostPosted: Sat Aug 25, 2007 3:04 am    Post subject: No joy... Reply with quote

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
Back to top
View user's profile Send private message
paulodeon
n00b
n00b


Joined: 24 Aug 2007
Posts: 4

PostPosted: Sat Aug 25, 2007 3:32 am    Post subject: Got it! Reply with quote

Found the cause of the problem on the following gentoo forum post http://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 :D
Back to top
View user's profile Send private message
tecknojunky
Veteran
Veteran


Joined: 19 Oct 2002
Posts: 1937
Location: Montréal

PostPosted: Sat Nov 17, 2007 2:55 pm    Post subject: Re: Got it! Reply with quote

paulodeon wrote:

<Directory /usr/lib/php4/bin>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Thanks! :D For once, the forum gave me the exact solution right away thanks to you.
_________________
(7 of 9) Installing star-trek/species-8.4.7.2::talax.
Back to top
View user's profile Send private message
bfx81
n00b
n00b


Joined: 25 Oct 2006
Posts: 16

PostPosted: Sun Jun 15, 2008 4:33 pm    Post subject: Reply with quote

...same problem with php5-cgi
...same solution (well obviously adjusting the php5 bin path!)
_________________
In a world without walls... who needs windows?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum