Running PHP locally in Windows using WAMP XAMPP

Running PHP locally in Windows using WAMP XAMPP

Running PHP locally has been a challenge for new developers all the time. In this article, I will brief the method in which you can quickly set up a local server connection. After that, running PHP locally would be very easy.

PHP, or Hypertext Preprocessor (earlier known as personal home page), is a web scripting language that helps in converting a static webpage to dynamic.

Learn more on Static and Dynamic webpages.

PHP can run by itself using a server configuration and a database connection (if you include database functionality in your webpage). Running PHP locally means that your hard disk behaves as the server storage space. The Apache software (in case of WAMP / XAMPP) creates port for communication and configures the server access variables.

WAMP (Windows Apache MySQL PHP) or XAMPP are both software to be used in conjunction with Windows operating system. So, it is like using a Windows server in a hosting plan. This software does not work in Linux. For Linux users, you must use LAMP software.

So, let’s start with understanding the basics of running PHP locally –

  1. Installation of the WAMP software
  2. Writing our PHP file and storing it inside www
  3. Opening our server page on the browser and running PHP locally

First of all – let’s install WAMP for running PHP locally on our computer

The WAMP or XAMPP software is readily available on the Internet. If you are finding it very difficult to get hold of them, here’s my list of links that will help you –


Download the software from one of the above links before you try running PHP locally. This software behaves as the host configurator and must be installed first. Once you have downloaded WAMP / XAMPP, start installing it. It’s a simple job if you follow each procedure step by step.



  1. Use administrator rights to continue with installation when you first click the setup file.
  2. The next few steps are very easy. Just like installing any other software, you must accept terms; select the path for installation, etc.
  3. After the installation starts, in the middle you would be asked about your default browser. Just click okay when it shows explorer (by default it sows explorer, so click ok in the default popup window).
  4. That’s it. The software for running PHP locally is now installed. Now click on the shortcut icon to start WampServer.
  5. To check whether it is running or not, look for the below icon in the taskbar.


Storing your files in the dedicated folder

Your PHP projects must all be stored in a particular folder in order to be accessed by the host (localhost) before running PHP locally. WAMP provides a folder named “www” within the folder where it has been installed. On the other hand, XAMPP provides a folder named “https”.

All your PHP files and projects must be within this folder. You can keep the files in dedicated folders or just randomly (I do not suggest this at all!). When you access the project via your browser, you would access this folder first and then go down the folder hierarchy.

Now let’s switch to running PHP locally from the browser.

Running PHP locally – steps in the front end           

Once the files and installations are all at place, just open your browser and type in “localhost”. Make sure you have turned on WAMP or XAMPP before accessing the browser.

When you write localhost now, it means the browser straight heads to that “www” or “https” folder. So, now if you call a particular folder after “localhost”; that respective project would run.

So, let’s say you had stored all your PHP, HTML, CSS files for a single project inside a folder named “project101”. Now you moved this folder inside your “www” or “https”. When you have done this, for running PHP locally and running your project, just type in the following –

“localhost/project101/” and hit enter! Your project will be live on your computer!


Running PHP locally while accessing and associating a database    

Accessing a database is quite tough for beginners in the web domain programming zone. People really find it very difficult to work with databases while coding in a web scripting language. Well, let me tell you that PHP has a very short, simple and user friendly syntax. Just a bit of research and you’ll find it super easy to access database values from your PHP code.

Well, running PHP locally while using database is very easy. You must first create a database using WampServer on your computer.

Look at the image below –


This is how you access the database section for your local server. All your local projects that have database access and requirements can be handled from the “phpmyadmin” section.

The following image shows the phpmyadmin dashboard. This is your hub for accessing database values and entities. You can fully edit and update database values and settings from the phpmyadmin page.

That’s all. Use WAMP or XAMPP for running PHP locally and let me know.

  • This is something which I was seriously looking from some time. I just have a few queries, which I am sure you can be able to rectify. How much space is required for running PHP locally? How can I run WordPress on local? And how it be associated with my live site? I am sure Kaustav you can provide responses to these questions of mine…. Thanks in advance…

    • Hi Alok,

      Thanks for taking time and reading.

      You have mentioned quite a lot of questions and very important ones I must say! Please give me a few days of time and I shall write a pitch on your mentioned questions (since the questions have detailed answers, it’s not feasible to write the whole thing in the comment section).

      As for now, I can say that PHP runs at a very small space. PHP itself is installed along with APACHE server and MySQL in a small bit of memory space (approx. 200MB).
      Running WordPress is simple if you know how to install WordPress. Just like you install it on the server, the same way. If you do not know, you’ll have to wait for my article.
      Associating a local version of WordPress with the online version is simple. I do it myself. I create themes in local server and once it is ready I upload it to the live server. You can also export and import WP pages and posts.

      I will compile an article about these and send the link to you for your help.
      Fantastic comment Alok!

      • Sure Kaustav, I asked you the questions only because I wanted those information from you, and I was aware that you will have to create a blog post for that :) Thank you so much for telling the basics, though I was aware about it, but was not getting the courage to install just because I was a bit reluctant considering the space required for it….

        Thanks for clearing the doubts…

  • Very interesting! I saw this guide some time back and you nailed it with this one. Keep it up man! Great write!


    • Hi Reginald,
      Tons of thanks bro for taking out time and reading my write-up. I hope you found it good and useful. Thanks a lot! Nice to find you on my blog. Hope you drop by often…

  • Good one but I wanna know how to put my wampserver designed website online to access from entire world??

    • @disqus_6TfXryL6aV:disqus you must transfer all files from local folder to a hosted account space on the Internet. Hosted spaces are linked to domain names through DNS configurations. So, after you do the transfer, the respective domain name will show your website files online.

      • It seems like you are saying to purchase hosting & domain name right?? but i want to publish without both of them i mean like #wampserver already hosting after putting server online and domain name may be ip address or forwarding port…. can we publish like this or not??

        • Yes @disqus_6TfXryL6aV:disqus I got what you are trying to do. You are trying to use your own computer as the server, right? I did that while presenting my college web project. But even that requires your computer to be connected to a network (WAN or LAN). In that network, your computer will be connected to several other computers or laptops, etc, There, your computer will act as the server containing the files and the database. Other machines will type in your IP address and then the path of the project folder.

          I hope you have got what I tried to explain and I hope I explained what you wanted to know. :)

          Do subscribe and follow my blog. Cheers!

          • sorry to irritate you bt still i am talking about publishing my project in internet.. is that possible?? if i give my ip address and port whatever requirement to my US client and put my server online, is that possible they can access my project from there only or no??

          • @disqus_6TfXryL6aV:disqus you are not at all irritating me. :)
            Well, I am not sure about the process you are saying. You want the world to access your computer as the source of the website. Theoretically it is possible because all websites are just an IP address on the server memory. But frankly speaking, I do not know whether it will work practically. Because the port address configuration for PHP, MYSQL and Apache in WAMP server and online servers might not sync. This is because WAMP is a software to virtually create a server and host setup.
            However, you can try and do let me know…

          • Thanks for all reply ….. i am trying to do so.. …. if i get the solution than i will let you know….

  • Hi Kaustav,

    I am glad to know about the installation as I have learnt PHP in my starting days.
    I use it via Xammp.
    It’s an amazing software.
    Many developers try to figure out about running PHP in Windows or OS. There must read this post.

    Such a post worthy to follow.;)

    Enjoy your week ahead.


    • Hi @ravichahar:disqus ,

      Thanks for reading my article and commenting.
      Welcome to my blog and I am happy that you found it useful :)