| View previous topic :: View next topic |
| Author |
Message |
shadowShad n00b


Joined: 15 Dec 2005 Posts: 6
|
Posted: Thu Dec 15, 2005 6:33 am Post subject: [SOLVED]Configure Apache to work with PHP4 and PHP5 |
|
|
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 |
|
 |
danapsimer n00b


Joined: 07 Feb 2005 Posts: 13 Location: Atlanta, GA
|
Posted: Thu Dec 15, 2005 6:42 am Post subject: |
|
|
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 |
|
 |
shadowShad n00b


Joined: 15 Dec 2005 Posts: 6
|
Posted: Thu Dec 15, 2005 7:27 am Post subject: |
|
|
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 |
|
 |
pjp Administrator


Joined: 16 Apr 2002 Posts: 15989 Location: Colorado
|
Posted: Thu Dec 15, 2005 5:39 pm Post subject: |
|
|
Moved from Other Things Gentoo _________________ Safety is my gaol.
US Constitution | Amendments |
|
| Back to top |
|
 |
c4 Guru

Joined: 21 Feb 2004 Posts: 312 Location: Sweden
|
Posted: Thu Dec 15, 2005 7:35 pm Post subject: Re: Configure Apache to work with PHP4 and PHP5 |
|
|
| 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 |
|
 |
shadowShad n00b


Joined: 15 Dec 2005 Posts: 6
|
Posted: Fri Dec 16, 2005 6:54 am Post subject: |
|
|
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 |
|
 |
shadowShad n00b


Joined: 15 Dec 2005 Posts: 6
|
Posted: Fri Dec 16, 2005 7:29 am Post subject: |
|
|
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 |
|
 |
Rebuke n00b

Joined: 14 Jan 2005 Posts: 4
|
|
| Back to top |
|
 |
NautilusIII Apprentice

Joined: 23 Nov 2003 Posts: 162
|
Posted: Tue Aug 01, 2006 7:04 pm Post subject: |
|
|
| YES, please add this to the guide!!! |
|
| Back to top |
|
 |
|