/    Sign up×
Community /Pin to ProfileBookmark

php not working with apache

Ok, i’m extremely new and therefore extremely ignorant in the web development area. I apologize in advance for such basic questions.

I installed Apache2 and PHP 5 on my windows XP box and after following the install.txt that came with PHP to configure apache2 to accept and process php scripts (i configured as an apache module as opposed to a cgi binary). I configured the httpd.conf file in apache just as the document said.

if i try to name a file index.php, the file will have the standard generic unknown file icon next to it (as opposed to say .java or .pl file which will have some proprietary icon image) which lets me know that it doesn’t recognize a .php file. In addition, when i try to access the index.php file through the web browser, the folder content tree just comes up. Now I did rename it to index.html, but the dumby hello world php script that i wrote didn’t show up, it was just a blank page

dumby script:
<html>
<? echo “hello world”; ?>
</html>

What could be wrong? why aren’t my .php files not being recognized?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TOct 14.2005 — Installing PHP/Apache doesn't associate PHP with PHP files, it just means that when you contact one of those files through the server the PHP engine will parse it.

The reason it doesn't work in a browser is because you are probably double-clicking the file to open it in the browser. Instead, you have to open it through the server.

Open up your browser and go to http://localhost/ and you will be at your web root directory (htdocs directory in apache folder). Anything you place in your htdocs folder can than be accessed through the browser. For example, if you saved that file you made as index.php and put it in htdocs, you would open up this page in the browser: http://localhost/index.php (or simply http://localhost/ since it is an index page)
Copy linkTweet thisAlerts:
@ridicimousmanauthorOct 14.2005 — yeah i tried that....index.php is in my htdocs folder, opened up a browser and typed in the localhost url in the browser, and whati get is the web directory or whatever, basically a display of the files in my folder, or if i rename it to index.html and do the same thing, it'll come up with a blank html page, totally ignoring the hello world embedded php code.
Copy linkTweet thisAlerts:
@Daniel_TOct 14.2005 — Okay then, you need to set a line in httpd.conf. Do a Find for "DirectoryIndex". If it's found, edit that line. If not, add this new one:[code=php]DirectoryIndex index.php index.php3 index.html index.htm[/code]
Copy linkTweet thisAlerts:
@ridicimousmanauthorOct 14.2005 — ok it works now, i already modified the dirindex and added index.php....i'm really not sure what happened, as it went from not working to working and i personally have not changed anything before and after this mysterious transition, which kinda scares me should another problem similar to this comes up in the future i wont' know how to solve it, but thank you very much for ur assistance.....by the way....i have index.php index.html and so forth....but what is index.php3???
Copy linkTweet thisAlerts:
@Daniel_TOct 14.2005 — It's a really old file extension that PHP 3 files used ? Probably not necessary, but if you ever want to use an out-dated script, it may have files with that extension.
×

Success!

Help @ridicimousman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...