First of all to create and host a website from your own local computer you need a server installed on your system. XAMPP is a light weight server which can be easily downloaded and installed on your system in few minutes. There are different versions of XAMPP server and are compatible with different versions of windows, one should download accordingly. To download XAMPP server open the URL: https://www.apachefriends.org/index.html. XAMPP stands for Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P). XAMPP is an open source package, means anyone can download and use it on his system for free.
Click on XAMPP for windows to download the XAMPP version for windows. Download the exe file and double click on it to install.
Click on next to continue installation.
Click on next.
Click on next to continue the installation.
After finishing the installation, it will ask to start the XAMPP control Panel.
Start Apache and other components as per your need.
The default index file in the folder c:\xampp\htdocs\ will open. You can keep it or delete/replace it with your own file. The files in htdocs folder are default and only for learning purpose. You may delete these files.
Now open a new notepad file and type the following:
<?php
echo ‘Welcome to Mysite’;
?>
And save the file as index.php and save it in the folder:
c:\xampp\htdocs\ (or whichever directory you installed XAMPP in).
Again type localhost in your browser and you will see the message “Welcome to Mysite.”
Now to use your custom name instead of localhost you have to do some changes in the hosts file residing in the folder:
C:\Windows\System32\Drivers\etc
Copy the hosts file to the desktop or other directory and open it with notepad or other editor.
It will look like:
Now replace the file in folder C:\Windows\System32\Drivers\etc\hosts with the hosts file saved on Desktop.
Important Note: Don’t ever try 127.0.0.1 www.google.com or other real website name in this hosts file as this is to map IP address to a website on your computer. So whenever you try this using website name like google and try to open google in your browser, the webpage saved in folder c:\xampp\htdocs\ will open and not the real website of google.
Now type www.mysite.com in your browser and see the magic. Whatever changes you make in the file c:\xampp\htdocs\index.php it will reflect in your local website www.mysite.com.
This way you can test your HTML or PHP files and can see how your website looks.
Now to see your website from other device or computer connected in your local network, just type your IP address in the browser of that system.
This way you can test your HTML or PHP files and can see how your website looks.
Now to see your website from other device or computer connected in your local network, just type your IP address in the browser of that system.
No comments:
Post a Comment