Travel Agency

Its my first time working with Apache,PHP,MySql. I downloaded and installed the latest package of these 3. Now I checked with apache and the index.html works. Now I replaced the index.html with some php script to check if my php works or not. When opened the html page again I see the php code directly. It seems it does not work. following is how my php code looks like.

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

when I open my index.php , I see the above code itself. Can anybody let me know whats wrong and how can i fix it?

share improve this question
 
    
Either your PHP isn"t correctly installed or the type .php hasn"t been added to your Apache configuration (httpd.conf) yet. – PeeHaa Jan 5 "12 at 2:48
    
Are you visiting the page through localhost/index.php or through your regular file system path to the file? Make sure you are using localhost. – Paulpro Jan 5 "12 at 2:48
1  
Try using wamp, it will be much easier to get set up and running. – stefan Jan 5 "12 at 2:49
1  
I suggest that instead of fixing what appears to be one issue, but is likely many issues with your apache installation (I have had alot of issues when I did it, trying to get php to talk to mysql and apache etc). I found this was so easy, i defineately recommend it. Install all 3 at once via one installer! See here for the download:sourceforge.net/projects/wampserver WAMP is the windows version. If you would like a linux version you could try LAMP. – Dessus Jan 5 "12 at 2:50
2  
Please note that you never install WAMP on your production machine. – PeeHaa Jan 5 "12 at 2:51

5 Answers

Check your apache httpd.conf file for some commented out code that looks like this

LoadModule php5_module libexec/apache2/libphp5.so

and further down the file, this...

<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
share improve this answer
 
    
I don"t find the libphp5.so file neither in my Apache or PHP installation locations. How to do it? Mine is httpd-2.2.21 apache and php 5.3.8. Please suggest. – Surjya Narayana Padhi Jan 5 "12 at 3:17
    
ah, I"m not on windows now, but wherever Apache installed to, look under conf/ and you should find this httpd.conf file. Either add or uncomment the lines I listed above – Mike V Jan 5 "12 at 3:19 
    
I found the httpd.conf file. But where can i find the libphp5.so file? so that I can set the path. Even in httpd.conf file also I dint find it commented. – Surjya Narayana Padhi Jan 5 "12 at 3:22
1  
How about a file that looks like this: c:/php/php5apache2_2.dll – Mike V Jan 5 "12 at 3:31
    
I"m done for the night, if this didn"t do the trick, check this question: stackoverflow.com/questions/873734/… - It looks similar to your situation – Mike V Jan 5 "12 at 3:37

it seems there is some problem in the installation. use WAMP as stefan and dessus or XAMPP. i recomand u to use XAMPP its bundled with APACHE, MYSQL, File Zilla Server, Mercury for mail. Easy to Install and Use . http://www.apachefriends.org/en/xampp.html

shareimprove this answer
 

Another vote for WampServer. Once you have a working server, it"s then easier to poke around with configurations files and then learn Apache/PHP configuration that way.

shareimprove this answer
 
    
Why the down-vote…? – Martin Bean Apr 27 at 9:21

use wamp! it"s easy and fast :)

http://www.wampserver.com/en/

personally, i use an old version from 2007, 1.7.4, it can be found here:http://sourceforge.net/projects/wampserver/files%2FWAMP5/

the good thing about using an old version is that your code will work on old machines, and many servers out there have old versions of php and mysql.

the bad thing about using an old version is that your code might not work on new machines, and some machines out there have new versions of php and mysql.

 

Source

Stackoverflow.com


کلمات کلیدی:


نوشته شده توسط Abteen 94/10/10:: 11:3 صبح     |     () نظر