How to host a Website for free

in website •  7 years ago 

Hosting a website that too for free is what you always wanted after you learned enough HTML, CSS, PHP and/or JAVASCRIPT to show the world your website that you developed. By the end of this article you will be able to create a webpage and host it on your device itself.

Installing WAMP/LAMP

If you have Windows OS download WAMP if Linux then download LAMP. WAMP/LAMP is a bundle of three softwares Apache HTTP web server, php and mysql. There are other web servers too but Apache is at some point either better than them or they aren't just free. For example IIS (Internet Information Services) which comes bundled with Windows is a free web server which you can easily set up in your device but that's a tutorial for some future article and NGINX which is believed to be better than both the above mentioned web servers yet isn't much of our interest here since it comes with a free trial period, hence not free.

Download Wamp here Wamp web server.

Wamp and www directory

To run wamp double click on the desktop shortcut of wamp to run it or go to the 'wamp' folder which you will find in the directory where you chose to install your wamp web server and run the wamp application. It will show in the hidden icons menu in the taskbar.

In wamp all of your web page documents which are to be hosted are supposed to be present in 'www' directory of wamp. You will find 'www directory' when you left click the wamp icon in the taskbar or you can go to where wamp is installed on your pc to access the same.

Goto this 'www directory' and make a new folder and move the already present 'index.php' there. I'll explain why we are doing this later but for now just follow through.

Creating a simple HTML document

Open notepad and type some html code into it if you are familiar with html or just copy the following html code and paste it in notepad. Save the file as 'index.php' in the 'www directory'.

<!DOCTYPE HTML>
<html>
<head>
<title>Hosting website for free</title>
</head>
<body>
<p style="text-align:center"> My first website </p>
</body>
</html>

Setting up wamp for web hosting

As I told you before, wamp is only a bundle of three softwares php, mysql and apache web server, it is not a web server in itself but Apache is which contains 'httpd.conf' configuration file of Apache. Left click on the wamp icon in the taskbar and in the Apache's menu find httpd.conf and open it. You can go to 'wamp/bin/apache/apache2.4.9/conf/' to find the same too.

Open a tab in your browser and type 'what is my ip' and press enter, it gives you your public IP address, copy it. Now find 'ServerName' in httpd.conf and replace 'local host' there with this IP address you just copied. It should look something like this...

Before -

ServerName localhost:80

After -

ServerName 127.0.0.1:80

As an example I have used local loopback address 127.0.0.1 here which means localhost only but you need to paste your public IP address here which you copied before. Save and close the httpd.conf file.

Now, open a tab in your browser and type in your public IP address and press enter. You should see this as your output-

accessing website through public IP address

If you are shown message - permission denied then open the httpd.conf file again and search for 'denied' and replace all 'denied' with 'granted', refresh the web page and there you go your first ever website hosted by you.

In case you still find others unable to find your website through your public IP address, go to your router's IP which is given on the back side of your router and is probably something like 192.168.x.x or 10.168.x.x and type that address in your browser, log in and use the DMZ feature to set your private address to receive all the undetermined traffic OR use port forwarding feature to achieve the same as DMZ only manually this time.

Problems

The reason that we are replacing localhost by our IP address is that we don't have a registered DNS name, we only have an IP address allotted to us by our DHCP server. You can tell your friends and everyone to type in your public IP address in their browsers on their devices and flaunt your website which they will be able to access from anywhere in the world but that major flaw with this is that you will need to give out your IP address to everyone which is putting your own device at a major risk.

Only solution to this problem is to buy a registered domain name and replacing 'localhost' in httpd.conf with that domain name and host your website on your device using Apache similarly. If your website is supposed to be online for forever then you will need to stay online with wamp for that long and only alternative is to let someone else host your website whose main purpose is to do the same.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

wow nice and informative

Very good for everyone with computer knowledge as it can save some cost.

  ·  7 years ago (edited)

thanks guys

Its works offline dear, wampp and xampp both are local host server they are not showing online to everyone

It will work online for everyone to see as well. You have to put your PUBLIC IP ADDRESS there in the httpd.conf file, as I have written in the blog too.
Then if you are on a home router you have to set DMZ to your PRIVATE IP or allow port forwarding on port 80 to your PRIVATE IP to let inbound connects talk to your device.

I'll be uploading a video tutorial for the same soon...I'll let you know.

Congratulations @ajax9496! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You made your First Comment

Click on any badge to view your own Board of Honnor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!