How to run PHP files on localhost?

October 30, 2008 by: Ranjith

1. First download the xampp from http://www.apachefriends.org/en/xampp.html
2. Extract the file and double click the exe. This will install Mysql and Apache servers.
3. Once the installation is complete, you will find XAMPP under Start / Programs / XAMPP. You can use the XAMPP Control Panel to start/stop all servers. Start Mysql and Apache servers.
4. Write a test.php file and copy it in to C:/Program Files/XAMPP/htdocs/
5. To run the php file, you just need to brows http://localhost/test.php

Note: You can also create any folder inside htdocs and past test.php inside the folder. If you create a folder called test then the address will become http://localhost/test/test.php

Share/Bookmark:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Furl
  • StumbleUpon
  • Technorati
  • email
Similar posts:

Comments

53 Responses to “How to run PHP files on localhost?”
  1. Zohaib shah says:

    Bro i installed wamp & iis with php designer both of them didnot work so i search on google and i find ure article i m really thankfull for ure efforts and hardwork work Ranjith Keep it up dude,,,,

  2. Shekhar says:

    Thank you Ranjith
    it solved my problem

  3. shah zeb says:

    very well tutor about running files on xampp and wamp

  4. Kuntal Gupta says:

    Simple and Nice Tutorial :D

  5. php file run says:

    Plese send me ho to run php file in localhost
    I Don’t konw how to setting in localhost
    But this file i create and save in www folder and run with localhost in interbet explorer i get a error file not found plese send me detials

  6. Amol says:

    I have php designer, wamp server, iis. But could not able to open the php file in browser. The file couldnt run. how to run php file.
    Plz send me the exact soln and Correct procidure to follow.

  7. bahram says:

    it works perfectly…

  8. ash says:

    realy a good one thanks

  9. vikas says:

    it’s so nice.

  10. ajay says:

    its a nice suggestion but i installed wamp server … but it needs start first to execute the progarm ….. is this necessary for all server or it necessary only for wamp server

  11. Rahul says:

    Thanks for sharing. Can we install Xampp in D drive..as i dont have much space to store my PHP project files in my C drive.

  12. sathi says:

    How can i run mysql, please explain with an example

    Thanks

  13. Aditya says:

    sir ,i am doing a college project in which i have to create a image gallery where different user can share the images and also music …so do what other tools do i need apart from xampp to make both front end and back end(database)

  14. thanks for this short & easy tutorial
    i got what i was looking for

  15. Shanmugam says:

    Thank u so much Ranjith, for explaining very simple way to install and run PHP. Cheers and Keep it up.

  16. Sabuj Sadhukhan says:

    Thanx for advise.
    It works.
    A good wish to you……………………

  17. zubair elahi says:

    BINGOOOO !!!!… i love u man .. i have been searching to run php for hours.. and thanks God i came across your article .. so simple and brilliant..
    i wish u best of luck in every walk of life :)

  18. Rajalakshmi says:

    I’m doing my fourth project so i wants to know how to run php… waiting for the reply…
    thanks….

  19. pras says:

    hi i was installed xampp in my windios but when i open my local host it opens the oracle http server so what i can do…………………………plz help me

  20. shahzad says:

    thanx it really is very simple

  21. gurjit says:

    I has been installed apche and control panel show me that apche has been installed in local host open scussessfully but my php file in htdocs are still show me as text file even i has been given a name extension in php. what i can now do.

  22. rapidcrack says:

    Remarkable facts pertaining to upload files for having myself personally begin. I am going to keep this specific website link and revisit it.

  23. Extraordinary information with regard to upload files for having myself personally get going. Most definitely i’ll keep this specific website link and get back to this.

  24. Kumar says:

    Dear Sir

    I have folloed as what you said, But my php file could not execut.
    plz suggest me

  25. deepika says:

    hi i had installed xampp but in that xampp apache is not working properly is there any way that i install apache individually and can run php file

  26. Samar says:

    when i try to run php file with localhost, it doesn’t run
    appear:Internet Explorer can’t display this web page”
    please, any one suggest to me what can i do as quickly as you can
    Thanks,

  27. bikerboy says:

    This method works. Thanks.

    For you guys who are confused, you have to run it through the cmd.exe.

    If not, during installation, make sure you create a shortcut on Desktop.

  28. suresh says:

    bro this is not working i m trying same thing to las t 30 min, but didnot get +ve result, do u have any other ans for the same.

    Thanx

  29. unknown says:

    Thanks Really a good work!!!!!

  30. sanket singh says:

    Thank’s a lot….

  31. hamp says:

    hey thaks for ur info but i have a problem with my xampp. i can test my all php script but i can test my mail script on xampp. it display a warnning message “Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() ” hwo can i fix this? when i check the same script on my remote server thats work but on xampp the same script dosent work. what is smtp and smtp port how can i verify that?
    do u have any idea?

  32. George says:

    Obrigado Ranjith pois mesmo essa informação ter sido escrita tanto tempo ela foi de muita utilidade…muito obrigado.

  33. George says:

    Thanks Ranjith because even this information has been written so long she was very helpful … thanks.

  34. Gulam Nabi says:

    sir apache server is not working well
    it is not going to start its still stoped
    wht reason i do not know

  35. ali says:

    hi
    ghulam nabi.you need to first close skype..then open xamp .it will surely work..

  36. uckiji82 says:

    A lot more webmasters like this website, amazing put up always keep up the superior do the job. Concerning saved yuor web blog.

  37. rashid says:

    i installed xampp and started appachi service.but when i run my file , following errors are occured.

    Object not found!

    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

    If you think this is a server error, please contact the webmaster.

    Error 404

    localhost
    8/23/2011 7:50:49 PM
    Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1

  38. It’s really a nice and helpful piece of information. I am satisfied that you just shared this helpful info with us. Please stay us informed like this. Thank you for sharing.

  39. JJ says:

    Thank you!!!!!!!!! I have spent days sifting through really complicated online tutorials and I still couldn’t figure this out. Then I found this and it’s so simple and it works!!!!!

  40. Monika Bhadja says:

    When i run php file i got error as following :

    Apache/2.2.14 (Win32) DAV/2 mod_autoindex_color PHP/5.3.1 Server at localhost Port 80

  41. Monika Bhadja says:

    when i run php file i got error as following :

    Apache/2.2.14 (Win32) DAV/2 mod_autoindex_color PHP/5.3.1 Server at localhost Port 80

  42. Deepak Sharma says:

    Monika change ur wanp server version.

  43. psreepalv says:

    Superb explanations, thank you for your sharing this content.

  44. 1995draft says:

    information | i am happy to find it thanks for sharing it here. Nice work.|Was an interesting article, thank you..|Thank for this great post, i like what you

  45. rimmz says:

    #

    i installed xampp and started appachi service.but when i run my file , following errors are occured.

    Object not found!

    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

    If you think this is a server error, please contact the webmaster.

    Error 404

    localhost
    8/23/2011 7:50:49 PM
    Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
    #

  46. Dinesh says:

    Found this tutorial Installing Xampp and Run PHP Codes on Windows

    http://planetghost.com/run_php_code

  47. Ankit says:

    hi, i am interested in link address with you….
    my blog address nsmsolutions.blogspot.com

  48. preethi says:

    hi, i’m new to php and i dono how to execute the php files and how to extract data from excel sheet using php. help me

  49. Ishwarya says:

    nice it’s easy to learn

Leave a Reply