Set a domain as your localhost.

 xampp

XAMPP is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.

 domain

You can use your desired domain instead of using http://localhost,  like www.rastaval.com as a sample. It will even work even without internet connection.

Here are the simple steps:

1. Install XAMPP in your local computer. You can get it here for free. XAMPP

2. After a successful installation, you need to modify your “hosts” file.

It can be found in these directories:

c:\WINDOWS\system32\drivers\etc

Edit the “hosts” file with your favorite text editor.

3. Find the following texts:

127.0.0.1 localhost

Add some configuration below on it:

127.0.0.1 rastaval.com
127.0.0.1 www.rastaval.com

It should now look like this:

127.0.0.1 localhost
127.0.0.1 rastaval.com
127.0.0.1 www.rastaval.com

4. The next thing to do is to create a directory for your webfiles in the htdocs directory in xampp. Example of a directory name is “rastaval” (without double quotes).

I personally suggest to choose a directory name  for a specific domain.

5. The next thing to do is to explore the following directories:

C:\xampp\apache\conf\extra

Find edit httpd-vhosts.conf with your text editor.

6. Find #NameVirtualHost *:80:

Remove # to uncomment the line.

7. Create a virtual host. As what I did on my configuration with the domain www.rastaval.com in my localhost, it looked like this:

<VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs/rastaval”
ServerName rastaval.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs/rastaval”
ServerName www.rastaval.com
</VirtualHost>

NOTE:* Be sure everyline of the configuration is not commented or prefixed with #.
Be sure you have created separately for the with www and non-www domains.

8. To check if it is working, create a file and save it as index.php

Edit index.php and enter this simple php function:

<?php
$host = $_SERVER[‘HTTP_HOST’];
?>

<h1 style=”text-align:center;”>
PHP configuration of <?php echo $host; ?></h1>

<?php
phpinfo();
?>

Save it and it should be placed inside the rastaval directory to make it as a starting page for our domain www.rastaval.com

9. Now, run your XAMPP Control Panel, and tick Svc and Click the corresponding Start button for Apache. If you wish to use a database for your site, then you need to run MySQL as well. Ticking Svc means, the application will run as a service and everytime your computer starts, XAMPP will automatically run.

10. Open your favorite web browser, and I recommend Firefox, Flock or Google Chrome to use as your default web browser.
Type in the address bar, http://www.rastaval.com

testing

11. And you’re done. If you wish to create more domains in your localhost, you can just repeat the procedure. Happy Hosting 😀