Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error 403 with PHP on WinXP Pro SP2 1

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

Hane been faithfully following the tutorial Learn to install Apache, MySQL, phpMyAdmin & Zend Optimizer.

Apache and MySQL installations are OK but to test PHP, a file phpinfo.php containing
Code:
<?PHP phpinfo(); ?>
is created in the /htdocs folder and accessed by IE as
Code:
[URL unfurl="true"]http://localhost/phpinfo.php[/URL]
Instead of the expected content, the displayed page is an error page showing 'HTTP Error 403 - Forbidden' etc.

What's missing please?

TIA


FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
you need to give the user under whose credentials apache is running the correct permissions to read from the directory in which your file resides.
 
jpadie

Thanks for your response.

jpadie said:
you need to give the user under whose credentials apache is running the correct permissions to read from the directory in which your file resides.
How do you implement that please?

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 

From the Apache access log - there are no references in the Apache error log, unless I'm looking in the wrong place
Code:
127.0.0.1 - - [24/May/2006:12:44:18 +0100] "GET /phpinfo.php HTTP/1.1" 304 -

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 

Following jpadie's comments concerning correct permissions, have come across this article

Unable to run Perl or PHP in Application Pool Isolation.

Assuming this to be relevant to Win XP Pro,
Code:
Enter the object names to select box type IIS_WPG...
what value should 'IIS_WPG' etc be?

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
i don't think that application pools are your issue - it is a term that relates to IIS

you should have supplied a set of credentials during the installation of apache on the box. it is these that are relevant (assuming you are running apache as a service). to test the credentials bit why not go to your web root and give everyone read permissions. you can turn this off when your installation is up and running.

the error log is usually at
c:\Program Files\Apache Group\Apache2\logs\error.log

does apache work at all? if you browse to do you get a page?

if apache is working, have you correctly configured it to serve php pages?

assuming you are running apache 2 and are wanting to use php as a server module you need this in your httpd.conf file (taken from php.net manual)

Code:
# For PHP 4 do something like this:
LoadModule php4_module "c:/php/php4apache2.dll"
# Don't forget to copy the php4apache2.dll file from the sapi directory!
AddType application/x-httpd-php .php

# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

then restart apache using the supplied utility
 
Code:
if you browse to [URL unfurl="true"]http://localhost[/URL] do you get a page?
Yes, home page as expected.

Somewhere along the line the file php-5.1.4-installer.exe has not installed the required files.

The C:/WebServer/PHP folder contains only the folders

BACKUP (contains php.ini)
sessiondata
uploadtemp

and only the files

IISconfig.exe
install.txt
License
php5ts.dll
php.exe

so the .dll you referenced is not available anywhere.

I have the file php-5.1.4-Win32.zip which presumably does contain all the files.

The attraction of the tutorial was that all the folders\files would be under the C:\WebServer folder.

It would seem easier to start again with PHP installed in the root of C:\ - any thought on this?

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
then you are configured to run php as a cgi - i do not recommend this.

i absolutely think it is better to build your systems from scratch - not relying on other scripts to do things for you. by doing this you get to understand how things fit together.

but you have a working apache installation so let's work with that.

unpack the latest version of php in the webserver/php directory.

create your php file and make sure you tell it where your extensions are to be found (usually c:/webserver/php/ext). do not try load any extensions yet.

right click on my computer and select properties. In the advanced tab, select environment variables. find the "path" variable in the bottom box and edit it to include "c:\webserber\php".

change the permissions on the files phpts, phpapache2.dll to allow execution by the user under whose credentials apache is running. do the same to allow write access to php.ini. If this is a dev box with no external access you might just make the whole directory world read-writable.

now add these lines to your httpd.conf file
Code:
LoadModule php5_module "c:/webserver/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/webserver/php"
restart apache. try your phpinfo test again.

now try to install mysql with the zip file from the mysql website. make sure you install it as a service when it asks you the question

once installed, copy the files libmysql.dll and libeay.dll from c:/webserver/php to c:/webserver/php/ext

now edit php.ini and uncomment the mysql extension. save and close the file.

open a command prompt and navigate to c:\webserver\php. type php and see whether you get any error messages. if not press CTRL-C and exit the command prompt.

restart apache again and try a phpinfo test.

personally i prefer always to create my own installations. that way i know they are secure and i also get a feel for how they will interact together and with my systems. on windows boxes i use IIS. unless you have the server version you can't use virtual sites but that's usually no big deal for a dev or desktop machine.
 
jpadie said:
create your php file and make sure you tell it where your extensions are to be found (usually c:/webserver/php/ext).
What do you mean by this, please?
jpadie said:
change the permissions on the files phpts, phpapache2.dll...
I assume you mean php5ts.dll and php5apache2.dll?



If so I already have full control as administrator.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
i meant php.ini file.

php distro's come with two variants one called recommended and the other (i think) distribution. choose either and rename it php.ini. go through an change the settings you want - the files provide a description of each setting including a parameter for where php should look for its extensions.

I assume you mean php5ts.dll and php5apache2.dll?
yes

If so I already have full control as administrator.
your control is not relevant here - it is the control of the user under whose credentials apache is running that is the important one here.
 

Apache has been reinstalled into C:\server and is working OK. MySQL has not been reinstalled.

The following code has been added to c:\server\conf\httpd.conf
Code:
LoadModule php5_module "c:/server/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/server/php"
PHP has been unpacked to C:\server\PHP and C:\server\PHP\php.ini.dist renamed to C:\server\PHP\php.ini

In the "Paths and Directories" section in C:\server\PHP\php.ini there is
Code:
doc_root = "c:\server"
and below that there is
Code:
extension_dir = "c:/server/php/ext/"
If the additional code in c:\server\conf\httpd.conf is commented out, Apache will start, otherwise it won't.

What's missing, please?



FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
jpadie said:
In the advanced tab, select environment variables. find the "path" variable in the bottom box and edit it to include "c:\server\php".
This has also been done.


The error reported in the DOS window is
Cannot load C:/server/PHP/php5apache2.dll into server: The specified module cannot be found

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
the error message indicates that the relevant module is not present in the directory. i assume that you have checked that it is ;-)

i'm guessing that you may be using apache 2.2. in which case you need to use the php5apache2_2.dll which is available in the more recent snapshots of php (after or equal to 5.2). thus i'd recommend next step as downloading the latest snapshot of php. stop the server, delete the current php directory except for php.ini, copy the contents of the zip file into the now empty directory tree, restart the server and see what happens.
 
jpadie

The index.html and phpinfo.php both work as hoped for, without any futher modification.

Leaving php.ini in the \php folder and modifying the Windows path does seem cleaner than dumping it in the Windows folder.

A star and a big thank you for all your efforts! [smile]


FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top