How to host a website locally in your own pc by using WAMP?
There are two most porpular ways one can use to host a website locally one is XAMPP and the other is WAMP.
WAMP is an acronym that stands for “Windows, Apache, MySQL, and PHP”. When you download a WAMP, you are just downloading a program that installs three different things.
WAMP is an acronym that stands for “Windows, Apache, MySQL, and PHP”. When you download a WAMP, you are just downloading a program that installs three different things.
Apache – This is the program that is used to actually host your website. With it alone, you can host HTML files and other static web content.
MySQL – This provides a database for your web content. A lot of dynamic web pages need to store data (i.e. usernames and password for web accounts), which is where MySQL comes in.
PHP – The most popular language for writing dynamic web content – by far. WordPress, Facebook, Joomla, and many other websites and content management systems utilize PHP. If you plan to host anything more than static web pages, PHP will be an essential companion.
Windows – The “W” in WAMP is just there to specify that the program is compatible with Windows operating systems.
Before we proceed, please understand that hosting a website on an everyday PC and a consumer-grade internet connection is not recommended for anything beyond testing purposes and/or hosting a small website for a few visitors. Remember, the next time Windows Update needs to restart your system, your website goes down along with it – not an ideal situation for a serious website.
Installing WAMP
There are a lot of WAMP programs available, but we’ll be working with WampServer. Head over to their website and download the latest version of their program, then start the installation.
The installation prompts are self-explanatory; just keep everything at its default value and keep clicking Next. You can just click Open on this prompt to have WampServer use your default browser whenever you choose to look at your website:

Be sure to also add the security exception for Apache in Windows Firewall:
When the installation completes, check the box that says “Start WampServer 2 now” before hitting Finish. You should see the program running in your notification area.

Left click on the icon and hit “Localhost” at the top of the selection menu to open your website.

The default page currently just shows us a quick information page so we can confirm that all components are working properly. If you see this screen, then you’ve successfully installed a WAMP server.
WAMP Configuration
To change the page(s) that your web server displays, open the www directory by left clicking on the WAMP icon in the notification area.

The folder that opens is where you need to put any files that you’d like to host on your website. Anything from WordPress installation files to static HTML files can be placed in here, and the changes will be reflected on your website at the same time (just click refresh).
Let’s look at a quick example for how you would drop content into that folder for it to be served up on your website. You can use a web development program or something as simple as Notepad to create a basic PHP page and put it on your website.
The following code will be a good start:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Paste that code into Notepad and save your file as index.php inside of C:\wamp\www

Now return to your website (or hit refresh [F5] if you already have it opened) and you’ll see the page you just created.

By default, your website is currently only accessible by the computer that WampServer is installed on. That’s perfect for anyone who’s just using their WAMP server for testing or development purposes, but to make your website accessible to the rest of the world, click on the WampServer icon and click “Put Online”.

By default, the Apache configuration file is set to deny incoming connections from everyone except for the localhost, so you’ll also have to change two lines of code so other devices don’t see a “403 Forbidden” error whenever they try to load your site. Access httpd.conf (Apache configuration file) by left-clicking the WampServer menu and looking under the Apache folder.

Scroll down until you see some code that says:
Order Deny,Allow
Deny from all
Delete this code and replace it with:
Order Allow,Deny
Allow from all
Save the changes to the httpd.conf and restart all services.

Your site should now be accessible from the World Wide Web. If not, ensure that you have forwarded port 80 to your computer on your router.
Comments
Post a Comment