pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

HOW TO CONFIGURE VIRTUALHOSTS WITH APACHE IN WINDOWS (IN 2 STEPS)

When working with Apache on Windows, the most usual is to use WampServer or Xampp.

These “packages” allow us to install Apache, MySQL and PHP in a single pass.

And the result is as follows:

Our projects will be saved in a certain folder (usually wwww in Wamp and htdocs folder of Xamp).
We can access our projects by visiting the local host.
What we are going to configure now will allow us to access our projects from different directions.

This is very useful for Laravel projects, because it allows us to access our projects using my-project.localhost instead of localhost/my-project/public (this way we can avoid the use of php artisan serv and use Apache as server).

Configuration in 2 steps
The configuration that we are going to make consists of 2 steps.

First we are going to tell our operating system that when looking for the address localhost subdirectory of the folder, resolve this request through our local server (and do not search this page publicly on the Internet, as normally happens).

Then we’ll tell Apache how to resolve an incoming request for my-project.localhost (since Apache usually doesn’t know how to react to it).
File hosts and Virtual hosts
I know you’re eager to do the setup now.

As the title of the article says, it’s simply 2 steps.

If you’re in a hurry, you can skip this section. However, I recommend you continue reading.

Step 1

Hosts file

Every operating system presents a hosts file, to save the correspondence between Internet domains and IP addresses.
The location of this file depends on the operating system.
We will modify this file in step 1.
Virtual hosts

The creation of virtual hosts (or VirtualHosts) allows the same computer to resolve multiple domain names.
In our case we are going to tell Apache to resolve certain addresses through our local IP.
We will do this in step 2.
VirtualHosts are useful in different scenarios.

In this case, we will use them to configure our local development environment.

Well, let’s get started.

On Windows, the hosts file is located at hosts subdirectory within the drivers folder in System32.

This file allows us to map host names with IP addresses.

A default hosts file usually includes only the following definition:

Here you can add as many addresses as you need. I’ll give you an example for now.

I’m currently developing an application that will probably be available from tawa.com.pe. Locally I can use localhost of tawa.

The important thing is to use a domain name that doesn’t exist (and can’t exist in the future) in order to avoid collisions.


Step 2


If so far I access tawa.dev.pe from the browser, Apache will resolve this as if it were localhost.

This is because we have not yet created a VirtualHost to serve this address. Let’s get on with it.

Apache has a configuration file. You must open this file.

In the case of Wamp it is located in the httpd.conf subdirectory of the apache2.4.23 folder. (if you’re looking at this article from the future, the version might change)
We can create Virtual hosts directly on this file. But not. Apache usually includes other configuration files on top of this main file to keep an order.

Within this file we find the following lines:

Virtual hosts

Include the httpd-vhosts.conf file extension in your window. This is necessary to make the local hosts virtual declaration.

This will help you get the virtual host up and running. The process is very straightforward, so you shouldn’t have to dedicate too much time to it.

Filed Under: Articles

Latest Articles

Benefits of Instagram as a Powerful Marketing Tool for B2B Brands

The ever-growing popularity of the social networking app Instagram makes it a popular channel for businesses to launch their services, advertising, and brand building strategies. B2B companies are, however, in two minds about the benefits of the site for them. Sure, the platform works great for B2C … [Read More...]

Take the Step for iPad Mini with Retina Display

Can you imagine holding a super portable, mini size and one hand iPad mini with 7.9 Retina Display? The retina display of this device has more than 3.1 million pixels – more that HDTV. It has a resolution of 2048 X 1536, which is four times compare to the early generation of iPad mini. With this … [Read More...]

Microsoft Debacle Emphasizes Importance of Quality Control in Software

Microsoft set off a chain of criticism when it rolled out its Windows update in 2018. This was a huge debacle that created a lot of frustration for countless customers, which reflected poorly on Microsoft’s brand image. Microsoft responded by assuring customers it would make quality control a … [Read More...]

Revolutionize Your Internet Experience with Orbi 960 – The Ultimate WiFi System

In a world where seamless connectivity is essential, slow and unreliable internet connections are a major problem. Whether you are running a business, … [Read More...]

Do You Need a VPN When Trading Cryptocurrency?

There’s no doubt that the biggest global industries in 2023 are tech-driven, while there remains a significant crossover between many of these … [Read More...]

Goodbye Bitcoin: the 3 alternative cryptocurrencies that have great upside potential, according to experts

Bitcoin has been a very lucrative investment for people that got into it early. One report from The Motley Fool pointed out that $10 of bitcoin … [Read More...]

Self-driving cars face their Achilles’ heel and may be targets of hackers

The market for self-driving cars is booming. Customers spent $22.22 billion on these autonomous vehicles in 2021 and they will likely spend more in … [Read More...]

How to avoid scams with bitcoin and other cryptocurrencies

Cryptocurrencies got a bad reputation when scams multiplied like ants on a piece of cake. Even today many people associate bitcoin and other … [Read More...]

WHAT IS CLOUD COMPUTING AND WHAT ARE ITS MAIN BENEFITS?

Users are Increasingly using cloud computing to store their information, which is replacing local storage. The business digitization process goes … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Modulation

Communication channels like telephone lines are usually analogue media. Analogue media is a bandwidth limited channel. In … [Read More...]

QIC Mammoth

The quarter-inch-tape cartridge (QIC) was first introduced in 1972 by the 3M company as a means to store data from … [Read More...]

The Browser Hijacker: CustomSearchPlus.com Virus

  The CustomSearchPlus.com is regarded as an unwanted browser extension, it is compatible with the popular internet browsers, namely, Internet … [Read More...]

[footer_backtotop]

Copyright © 2023 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors