Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]Configure Apache to work with PHP4 and PHP5
View unanswered posts
View posts from last 24 hours

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


Joined: 15 Dec 2005
Posts: 6

PostPosted: Thu Dec 15, 2005 6:33 am    Post subject: [SOLVED]Configure Apache to work with PHP4 and PHP5 Reply with quote

So hello every body.
I'm a newby in php, and I've tried to install 2 version of php on my server but I've some problems to configure Apache to work with PHP4 and PHP5.
I choose to put PHP4 working in CGI mode and PHP5 working as an Apache module. I've followed the Guid :
http://svn.gnqs.org/projects/gentoo-php-overlay/file/docs/php4-php5-configuration.html?format=raw
But I still have a problem, PHP5 work fine but PHP4 CGI doesn't work
When I try to view a file with .php4 extension I get this error :
Code:
You don't have permission to access /php4-cgi/info.php4 on this server.[/
code]
my file : /etc/apache2/modules.d/php4-cgi.conf
Code:
<IfDefine PHP4CGI>
    ScriptAlias /php4-cgi /usr/lib/php4/bin/php-cgi   
    Action php4-cgi /php4-cgi
    AddHandler php4-cgi .php4 .php3 .phtml
</IfDefine>


my file : etc/apache2/modules.d/70_mod_php5.conf
Code:
<IfDefine PHP5>

   # Load the module first
   <IfModule !sapi_apache2.c>
      LoadModule php5_module    modules/libphp5.so
   </IfModule>

   # Set it to handle the files
   <IfModule mod_mime.c>
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php .phtml
      AddType application/x-httpd-php .php5
      AddType application/x-httpd-php-source .phps
   </IfModule>

   AddDirectoryIndex index.php index.phtml
</IfDefine>


And I put in my /etc/conf.d/apache2 :
Code:
APACHE2_OPTS="-D PHP4CGI -D PHP5"


And for my virtual host I have :
Code:
<VirtualHost *:80>
    ServerAdmin toto@webserv.com
    DocumentRoot /home/toto/boulot/www
    ServerName localhost
   <Directory "/home/toto/boulot/www">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>   
    <IfModule peruser.c>
        ServerEnvironment apache apache
        MinSpareProcessors 4
        MaxProcessors 20
    </IfModule>
</VirtualHost>


I don't understand, can anyone help me


Last edited by shadowShad on Fri Dec 16, 2005 6:55 am; edited 1 time in total
Back to top
View user's profile Send private message
danapsimer
n00b
n00b


Joined: 07 Feb 2005
Posts: 13
Location: Atlanta, GA

PostPosted: Thu Dec 15, 2005 6:42 am    Post subject: Reply with quote

Have you checked the file permissions on the file and directory?
_________________
Consistency for consistency's sake is the hobgoblin of little minds - P.J. Plauger

Read my blog
Back to top
View user's profile Send private message
shadowShad
n00b
n00b


Joined: 15 Dec 2005
Posts: 6

PostPosted: Thu Dec 15, 2005 7:27 am    Post subject: Reply with quote

The permission file of the cgi script is :

for the command :
Code:
 ls -l  /usr/lib/php4/bin

Code:
-rwxr-xr-x  1 root root 1719748 Dec 14 13:58 php
-rwxr-xr-x  1 root root 1748820 Dec 14 13:58 php-cgi
-rwxr-xr-x  1 root root     738 Dec 14 13:58 php-config
-rwxr-xr-x  1 root root    4016 Dec 14 13:58 phpize


Is that you want to known? It's seems to me that the permissions are good no?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 15989
Location: Colorado

PostPosted: Thu Dec 15, 2005 5:39 pm    Post subject: Reply with quote

Moved from Other Things Gentoo
_________________
Safety is my gaol.
US Constitution | Amendments
Back to top
View user's profile Send private message
c4
Guru
Guru


Joined: 21 Feb 2004
Posts: 312
Location: Sweden

PostPosted: Thu Dec 15, 2005 7:35 pm    Post subject: Re: Configure Apache to work with PHP4 and PHP5 Reply with quote

shadowShad wrote:
When I try to view a file with .php4 extension I get this error :
Code:
You don't have permission to access /php4-cgi/info.php4 on this server.


I had an idea that perhaps it was the directory setting for Apache that was causing the error rather than being a PHP4 issue.
You say that php5 works fine, does this include files from withing the above directory?

I was thinking that perhaps you are using a common Apache setup with a default folder setting like
Code:
<Directory />
  Options -All -Multiviews
  AllowOverride None
  <IfModule mod_access.c>
    Order deny,allow
    Deny from all
  </IfModule>
</Directory>
thus denying access for everyone to any directory without an indexfile like index.html or index.php inside. I assumed you were opening http://localhost/php4-cgi/info.php4 and recieving the error?

I don't have any working setup with Apache at the moment so I can't check, but my guess was that because the directory was not specified in your vhost-setting, the directory was defaulted to " Order deny,allow Deny from all" and so you recieved the access forbidden error.

Also, have you checked the apache error-log for further information?
_________________
AMD64 Gentoo Hardened server
AMD64 Xubuntu Desktop
X86 Dreamlinux Vaio laptop
Back to top
View user's profile Send private message
shadowShad
n00b
n00b


Joined: 15 Dec 2005
Posts: 6

PostPosted: Fri Dec 16, 2005 6:54 am    Post subject: Reply with quote

You are right!!
Thank you the problem come from the apache configuartion file : /etc/apache2/httpd.conf

I let this directive by default :
Code:
<Directory />
      Options none
      Order Deny,Allow
      Deny from All
</Directory>


and indeed this directive denying access for everyone to any directory, and I haven't defining a vhost for php4-cgi,
if I coment this directive php4 cgi works fine, but I think that it's preferable to defining a vhost.

Thank you very much.
Back to top
View user's profile Send private message
shadowShad
n00b
n00b


Joined: 15 Dec 2005
Posts: 6

PostPosted: Fri Dec 16, 2005 7:29 am    Post subject: Reply with quote

by adding
Code:
<Directory "/usr/lib/php4/bin/">
    Options none
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


in httpd.conf the problem is solved and I cant let uncomented the default directive :[/code]

Code:
<Directory />
       Options none
       Order Deny,Allow
       Deny from All
</Directory>
Back to top
View user's profile Send private message
Rebuke
n00b
n00b


Joined: 14 Jan 2005
Posts: 4

PostPosted: Wed Apr 26, 2006 7:06 am    Post subject: Reply with quote

I followed the guide here http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml and ran into the same problem, is it worth adding this note to the guide as I'm assuming that myself and the OP are not unique ;)
Back to top
View user's profile Send private message
NautilusIII
Apprentice
Apprentice


Joined: 23 Nov 2003
Posts: 162

PostPosted: Tue Aug 01, 2006 7:04 pm    Post subject: Reply with quote

YES, please add this to the guide!!!
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
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