PHP5/Apache 2 Installation Question

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

renzo
New php-forum User
New php-forum User
Posts: 4
Joined: Fri May 20, 2005 2:02 pm
Location: philadelphia, pa

PHP5/Apache 2 Installation Question

Postby renzo » Fri May 20, 2005 5:30 pm

I am running Apache 2.0.54 and PHP 5.0.3 on a Windows 2K PE laptop. I first installed Apache and connected to http://localhost to test installation -- it worked fine. I then downloaded PHP5 (Binary) and followed configuration steps. I created a php test file (phptest.php) and saved to my doc_root (c:/www/apache2/htdocs). In this file I embedded php script into html script. When I go to my browser and type http://localhost/phptest.php, I get an error message "Error 404 - Page Not Found". I noticed that whenever I try to save the test file in Notepad, Windows insists on changing extension to .txt. In Apache error log, I see an error "Client 127.0.0.1 -- File Does Not Exist - C:/www/apache2/htdocs/phptest.php."

One other quick question: In PHP.ini file, what value should I put for "User Dir?" Should this be the location of my web docs (C:\www\apache2\htdocs)?

I am very new to PHP and programming in general, so any hints, suggestions or advice would be greatly appreciated.

Thanks,

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sat May 21, 2005 3:52 am

first of all: you need to enable view of known extentions (Folder options->view) and save the file with .php extention... another way would be saving it like this:

File name: "name.php"

Mind the quotes as they force notepad to save the file without adding .txt

I do NOT suggest using binary as its better to use zip packages... but it might be harder to configure... leave userdir as it is in php.ini : you dont really need it

renzo
New php-forum User
New php-forum User
Posts: 4
Joined: Fri May 20, 2005 2:02 pm
Location: philadelphia, pa

Postby renzo » Sat May 21, 2005 3:37 pm

Alexei, thanks for the pertinent advice. Since my last post, I was able to finally configure to parse my PHP code embedded in HTML files, but now I'm faced with a new problem: If I create a PHP file in Notepad and save it with either the .htm or .html extension, browser (or Apache) returns message "Page Not Found," but if I save the same file with the .html extension, the page loads fine. I'm just not sure where to look to resolve this one.

I'm almost up to speed, next I have to add MySQL component.

Thanks for all the advice.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sun May 22, 2005 1:51 am

i think its still that you are getting weird extentions... try showing known extentions like i told you..

by the way: its always better to use .php extention and not html for your php files... you did configure apache to use php, right?

renzo
New php-forum User
New php-forum User
Posts: 4
Joined: Fri May 20, 2005 2:02 pm
Location: philadelphia, pa

Postby renzo » Sun May 22, 2005 4:33 pm

Okay, I have view file extensions enabled. Files with PHP script embedded in HTML script are parsed in browser window, along as I use the HTM or HTML extension (i.e., File.htm). Browser will not parse the exact file with a PHP file extension.

Browser will parse files with PHP script alone (not embedded in HTML script) only if I use the HTML file extension (i.e., File .HTML). I've followed the Apache 2.0 configuration instructions and reviewed the settings -- I've also viewed the PHP configuration file, but I'm not sure what I should change or edit. I added PHP to Windows Path, added PHP file extension to Windows File Types, but still no luck.

At least I can parse my PHP script now, which is step 1 of my battle, but I know I should use the PHP extension when creating PHP files.

Thanks again for the advice.

Renzo

renzo
New php-forum User
New php-forum User
Posts: 4
Joined: Fri May 20, 2005 2:02 pm
Location: philadelphia, pa

Postby renzo » Sun May 22, 2005 6:48 pm

Alexei,

I figured out my problem!!! I added the following to the httpd.conf file:

ScriptAlias /php/ "c:/www/php/"

I closed and restarted the web server and attempted to connect using my test files in all three extensions (htm, html and php) and it finally worked.

Now to tackle MySQL, so I may be back.

Thanks again for your great advice!

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sun May 22, 2005 11:00 pm

all you actually neede to do is use AddType derictive for the PHP extention in apache config file (just like instructed on PHP.net) and resterat your server :)

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sun May 22, 2005 11:01 pm

please look at the sticky's that ive posted before as they may be usefull in future configurations

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Mon May 23, 2005 3:44 am

and try not using CGI way of configuring PHP with apache but as an Module


Return to “PHP Installation”

Who is online

Users browsing this forum: No registered users and 1 guest