<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>virtual hosts Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/virtual-hosts/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Tue, 19 Nov 2019 14:52:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.13</generator>
	<item>
		<title>How to Enable Apache Virtual Host in Windows 10.</title>
		<link>https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/</link>
					<comments>https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/#comments</comments>
		
		<dc:creator><![CDATA[roger]]></dc:creator>
		<pubDate>Tue, 19 Nov 2019 02:36:23 +0000</pubDate>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[apache web server]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[virtual hosts]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=15701</guid>

					<description><![CDATA[<p>Hello, how are you? In a previous article, we saw how to install Apache in Windows 10. Consequently, we can use all the possibilities offered by this powerful web server. In this opportunity, I will show you how to enable Apache Virtual Host in Windows 10. Enable Virtual Host in Apache As mentioned above, we [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/">How to Enable Apache Virtual Host in Windows 10.</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Hello, how are you? In a previous article, we saw how to install <a rel="noreferrer noopener" aria-label="Apache (opens in a new tab)" href="https://httpd.apache.org" target="_blank">Apache</a> in Windows 10. Consequently, we can use all the possibilities offered by this powerful web server. In this opportunity, I will show you how to enable Apache Virtual Host in Windows 10.</p>



<h2>Enable Virtual Host in Apache</h2>



<p>As mentioned above, we have learned how to install Apache. However, the configuration applied only allows you to set up a single website through the <em>localhost </em>address.  On the negative side, This configuration does not offer enough flexibility of work, as it limits to a single website. This is inconvenient, as it is likely to require more than one website to be mounted on the server. Especially for those applications that do not need a dedicated server. Fortunately, Apache allows the configuration of multiple virtual hosts. On these hosts, it is also possible to interpret the PHP language. Let&#8217;s see how to do it!</p>



<h2>Edit the index.php file</h2>



<p>The first thing we need to do is to modify the index.php file located in the next path: <strong>C:\Apache24\htdocs</strong>. If you want to know how to do it, check our post about <a rel="noreferrer noopener" aria-label="PHP (opens in a new tab)" href="https://www.osradar.com/how-to-install-php-in-windows-10/" target="_blank">PHP</a> in Windows 10.</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh2-1-1024x730.jpg" alt="Modifying the index.php file" class="wp-image-15703" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh2-1.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh2-1-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh2-1-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh2-1-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh2-1-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh2-1-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Modifying the index.php file</figcaption></figure>



<p>With this modification what we will do is change the message of the site to show <em>Default website</em>. This is to work more comfortable and not to confuse with the two virtual sites that we are going to add. After saving the file, reload the browser and the page should look like this:</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh9-1024x730.jpg" alt="localhost website" class="wp-image-15705" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh9.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh9-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh9-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh9-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh9-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh9-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>localhost website</figcaption></figure>



<h2>Edit the httpd-vhosts.conf file </h2>



<p>Next, we are going to edit the virtual host configuration in Apache. With this intention, please go to this address <strong>C:\Apache24\conf\extra</strong>, once there select the <strong>httpd-vhosts.conf </strong>file and modify it with your favorite text editor:</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh3-1024x730.jpg" alt="default httpd-vhosts.conf file configuration " class="wp-image-15707" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh3.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh3-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh3-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh3-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh3-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh3-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>default httpd-vhosts.conf file configuration </figcaption></figure>



<p>In the shaded area that we saw in the previous image, we can see the information that we have to edit. In this opportunity, we are going to add two virtual hosts called <strong>osradar1.com </strong>and <strong>osradar2.com</strong>. Please note that you can assign the name of your preference, you just have to modify the file to your liking.  In addition, we have also enabled port 80, but it is also possible to enable port 443. Thus, we&#8217;re going to replace that code with the following lines:</p>



<pre class="wp-block-code"><code>&lt;VirtualHost osradar1.com:80>
	    ServerAdmin webmaster@osradar1.com
	    DocumentRoot "/sites/osradar1.com"
	    ServerName osradar1.com
	    ServerAlias www.osradar1.com
		&lt;Directory "c:/sites/osradar1.com">
		   AllowOverride All
		   Require all granted
		   Options Indexes FollowSymLinks
		&lt;/Directory>
	    ErrorLog "logs/osradar1.com-error.log"
	    CustomLog "logs/osradar1.com-access.log" common
	&lt;/VirtualHost>

	&lt;VirtualHost osradar2.com:80>
	    ServerAdmin webmaster@osradar2.com
	    DocumentRoot "/sites/osradar2.com"
	    ServerName osradar2.com
	    ServerAlias www.osradar2.com
		&lt;Directory "c:/sites/osradar2.com">
		   AllowOverride All
		   Require all granted
		   Options Indexes FollowSymLinks
		&lt;/Directory>
	    ErrorLog "logs/osradar2.com-error.log"
	    CustomLog "logs/osradar2.com-access.log" common
	&lt;/VirtualHost></code></pre>



<p>Save the file to make the changes effective.</p>



<h2>Edit the httpd.conf file</h2>



<p>Next, we are going to modify the Apache configuration to load the Virtual Host module. With this in mind go to the next address: <strong>C:\Apache24\conf</strong>. Then select the <strong>httpd.conf</strong> file and open it with the text editor. Look for a line with the text <em>vhost, </em>approximately<em> </em>line number 515. Then delete the number sign (<strong>#</strong>).</p>



<ul class="wp-block-gallery columns-2 is-cropped"><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh5-1-1024x730.jpg" alt="" data-id="15711" data-link="https://www.osradar.com/?attachment_id=15711" class="wp-image-15711" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh5-1.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh5-1-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh5-1-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh5-1-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh5-1-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh5-1-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Default setting</figcaption></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh6-1-1024x730.jpg" alt="" data-id="15712" data-link="https://www.osradar.com/?attachment_id=15712" class="wp-image-15712" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh6-1.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh6-1-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh6-1-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh6-1-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh6-1-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh6-1-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Configuration to load the vhost module.</figcaption></figure></li></ul>



<p>By removing the numeral sign, then the line is used and the extra configuration that has just been modified is downloaded. Save the file to continue. Without leaving the file modification, please locate line 187 corresponding to <strong>vhost_alias_module modules/mod_vhost_alias.so</strong>. In the same way that was done with the previous line, it is necessary to delete the numeral sign.</p>



<ul class="wp-block-gallery columns-2 is-cropped"><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh7-1024x730.jpg" alt="" data-id="15714" data-link="https://www.osradar.com/?attachment_id=15714" class="wp-image-15714" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh7.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh7-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh7-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh7-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh7-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh7-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption> Default setting </figcaption></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh8-1024x730.jpg" alt="" data-id="15715" data-link="https://www.osradar.com/?attachment_id=15715" class="wp-image-15715" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh8.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh8-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh8-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh8-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh8-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh8-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Configuration that allows Apache to host more than one module.</figcaption></figure></li></ul>



<p>This modification will allow Apache to be able to host more than one website. Press Save to continue.</p>



<h2>Create folders to host virtual websites.</h2>



<p>As you may remember, in the previous steps we modified Apache to host two virtual sites called <em>osradar1.com</em> and <em>osradar2.com</em>. Well, it is necessary to manually create the folders where the necessary files will be stored so that the sites load correctly. First, go to the root of the C drive and create a folder named <em>sites</em>. Once inside it please create two new folders with the name of the website. In this case <em>osradar1.com</em> and <em>osradar2.com</em>:</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh19-1024x730.jpg" alt="Creating folders for virtual sites." class="wp-image-15717" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh19.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh19-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh19-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh19-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh19-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh19-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Creating folders for virtual sites.</figcaption></figure>



<p>Then enter the folder <em>osradar1.com</em> and create a new file called <strong>index.php:</strong></p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh20-1024x730.jpg" alt="Creates the index.php file" class="wp-image-15718" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh20.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh20-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh20-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh20-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh20-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh20-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Creates the index.php file</figcaption></figure>



<p>Now it is necessary to add the following configuration to the newly created <strong>index.php</strong> file. Thereupon, opens the file with the text editor and copies the following code:</p>



<pre class="wp-block-code"><code>&lt;html>
&lt;body>
	&lt;h1>Osradar 1&lt;/h1>
	&lt;p>Welcome to Osradar 1 site&lt;/p>
	&lt;/body>
	&lt;/html></code></pre>



<p>This procedure has to be followed in the folder <em>osradar2.com</em>:</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh21-1024x730.jpg" alt="Create the index.php file in the folder osradar2.com" class="wp-image-15720" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh21.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh21-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh21-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh21-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh21-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh21-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Create the index.php file in the folder osradar2.com</figcaption></figure>



<p>In the same way, we have to modify the <strong>index.php</strong> file adding the following lines of code. Open the file with the text editor and paste the following text:</p>



<pre class="wp-block-code"><code>&lt;html>
&lt;body>
	&lt;h1>Osradar 2&lt;/h1>
	&lt;p>Welcome to Osradar 2 site&lt;/p>
	&lt;/body>
	&lt;/html></code></pre>



<p>Save the files to continue. Please remember that every time we make a change in the Apache configuration, it is necessary to restart the service. This way the changes will be effective. </p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh10-1024x730.jpg" alt="Run the services.msc command and restart the Apache server." class="wp-image-15726" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh10.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh10-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh10-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh10-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh10-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh10-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Run the services.msc command and restart the Apache server.</figcaption></figure>



<h2>Edit the hosts file in Windows.</h2>



<p>Finally, we are going to edit the host file in Windows 10. This will allow the system to load correctly the virtual hosts we have just created. In that case, opens a CMD as administrator and enters the following commands:</p>



<pre class="wp-block-preformatted">cd drivers
cd etc
dir
notepad hosts</pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh14-1024x730.jpg" alt="Accessing the host file" class="wp-image-15723" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh14.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh14-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh14-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh14-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh14-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh14-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Accessing the host file</figcaption></figure>



<p>The last command will launch the notepad and it is necessary to add the following lines to the<strong> hosts</strong> file:</p>



<pre class="wp-block-code"><code>127.0.0.1 osradar1.com	www.osradar1.com
127.0.0.1 osradar2.com	www.osradar2.com</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh22-1024x730.jpg" alt="Hosts file finally edited." class="wp-image-15725" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh22.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh22-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh22-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh22-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh22-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh22-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Hosts file finally edited.</figcaption></figure>



<p>What we have done is added the IP address and the names of the websites we have just created. This way the system will be able to load them correctly.</p>



<h2>Testing virtual hosts in the browser.</h2>



<p>If you have followed to the letter the instructions I have given you, then it will already be possible to host more than one website on our Apache server. Remember that if you get any errors, then check if the files were edited correctly. To check if everything is OK, open the web browser and enter <em>localhos</em>t. Open two more tabs and enter the name of the websites we created, in this case,  <em>http://www.osradar1.com// </em> and  <em>http://www.osradar2.com// </em>And all three websites will be running simultaneously on the Apache server.</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh16-1-1024x730.jpg" alt="localhost in Apache webserver" class="wp-image-15728" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh16-1.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh16-1-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh16-1-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh16-1-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh16-1-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh16-1-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>localhost in Apache webserver</figcaption></figure>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh17-1024x730.jpg" alt="Sample website osradar1.com running in the browser." class="wp-image-15729" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh17.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh17-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh17-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh17-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh17-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh17-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Sample website osradar1.com running in the browser.</figcaption></figure>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="730" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/vh18-1024x730.jpg" alt="Sample website osradar2.com running in the browser." class="wp-image-15731" srcset="https://www.osradar.com/wp-content/uploads/2019/11/vh18.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/vh18-300x214.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/vh18-768x548.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/vh18-100x70.jpg 100w, https://www.osradar.com/wp-content/uploads/2019/11/vh18-696x496.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/vh18-589x420.jpg 589w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Sample website osradar2.com running in the browser.</figcaption></figure>



<h2>Conclusion</h2>



<p>Finally, we have seen how to enable Apache virtual host in Windows 10. This configuration will allow loading more than one website in the Apache server. Consequently, it will give us more flexibility to program websites. This is all for the time being, until the next time.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/">How to Enable Apache Virtual Host in Windows 10.</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to configure an Apache Virtual host on Debian 9?</title>
		<link>https://www.osradar.com/how-to-configure-an-apache-virtual-host-on-debian-9/</link>
					<comments>https://www.osradar.com/how-to-configure-an-apache-virtual-host-on-debian-9/#respond</comments>
		
		<dc:creator><![CDATA[angeloma]]></dc:creator>
		<pubDate>Thu, 13 Sep 2018 09:14:09 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[virtual hosts]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[webadmin]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=5712</guid>

					<description><![CDATA[<p>VirtualHost allows you to assign different websites across domains to the same IP address. They allow easy access to a PHP application hosted on an Apache web server through a simple domain. For this reason, is very used for web developers and system administrators. In this article, I will show you how to configure an Apache [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-configure-an-apache-virtual-host-on-debian-9/">How to configure an Apache Virtual host on Debian 9?</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>VirtualHost</strong> allows you to assign different websites across domains to the same IP address. They allow easy access to a PHP application hosted on an <a href="https://httpd.apache.org/">Apache web server</a> through a simple domain. For this reason, is very<strong> used for web developers and system administrators. </strong>In this article, I will show you how to configure an Apache virtual host on Debian 9.</p>
<h2>0.What you need</h2>
<p>Before you start, you must have certain requirements for everything to work perfectly.</p>
<ul>
<li>Have, at least, a notion of how to <strong>use the command line interface</strong>.</li>
<li>A user who can use sudo.</li>
<li><strong>A desire to learn</strong>. Vital to acquire the knowledge that I will give you.</li>
<li>A computer with Debian 9 installed. Obvious, isn&#8217;t it?</li>
</ul>
<h2>1. Install Apache web server</h2>
<p>Generally, before you start installing and configuring a system, it is a good idea to perform a general system upgrade. With this, you will obtain the last security patches.</p>
<p>Open a terminal and run on it:</p>
<pre class="">:~$ sudo apt update &amp;&amp; sudo apt upgrade</pre>
<p>After you enter your password, the update process will begin. As a result, you will have an updated and secure system.</p>
<p><figure id="attachment_5713" aria-describedby="caption-attachment-5713" style="width: 1368px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5713" src="https://www.osradar.com/wp-content/uploads/2018/09/1-5.png" alt="1.- Upgrading the system" width="1368" height="747" srcset="https://www.osradar.com/wp-content/uploads/2018/09/1-5.png 1368w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-300x164.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-768x419.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-1024x559.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-696x380.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-1068x583.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/1-5-769x420.png 769w" sizes="(max-width: 1368px) 100vw, 1368px" /><figcaption id="caption-attachment-5713" class="wp-caption-text">1.- Upgrading the system</figcaption></figure></p>
<p>Now, you can install apache2 from the official Ubuntu repositories. Run:</p>
<pre class="">:~$ sudo apt install apache2</pre>
<p><figure id="attachment_5715" aria-describedby="caption-attachment-5715" style="width: 1368px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5715" src="https://www.osradar.com/wp-content/uploads/2018/09/2-5.png" alt="2.- Installing apache2 web server" width="1368" height="747" srcset="https://www.osradar.com/wp-content/uploads/2018/09/2-5.png 1368w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-300x164.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-768x419.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-1024x559.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-696x380.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-1068x583.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/2-5-769x420.png 769w" sizes="(max-width: 1368px) 100vw, 1368px" /><figcaption id="caption-attachment-5715" class="wp-caption-text">2.- Installing apache2 web server</figcaption></figure></p>
<p>As a result, you can now go to your browser and set the IP address of the server and you will see a page similar to this one. Open it.</p>
<p><strong>http://IP_server/</strong></p>
<p><figure id="attachment_5717" aria-describedby="caption-attachment-5717" style="width: 1365px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5717" src="https://www.osradar.com/wp-content/uploads/2018/09/3-5.png" alt="3.- Apache2 deafult page" width="1365" height="702" srcset="https://www.osradar.com/wp-content/uploads/2018/09/3-5.png 1365w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-300x154.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-768x395.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-1024x527.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-696x358.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-1068x549.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/3-5-817x420.png 817w" sizes="(max-width: 1365px) 100vw, 1365px" /><figcaption id="caption-attachment-5717" class="wp-caption-text">3.- Apache2 default page</figcaption></figure></p>
<p>Good job. Apache is running smoothly on your computer.</p>
<h2>2.- Create web directory for each Apache virtual host</h2>
<p>In order to create a structure of efficient directories and that the Virtual hosts do not have problems, you must create a directory for each one of them. In this case, I will only create two virtual hosts. One called <strong>&#8220;osradar1.local&#8221;</strong> and other called <strong>&#8220;osradar2.local&#8221;</strong>.</p>
<p>Create the folders:</p>
<pre class="">:~$ sudo mkdir -p /var/www/html/osradar1.local/public_html
:~$ sudo mkdir -p /var/www/html/osradar1.local/public_html</pre>
<p><figure id="attachment_5718" aria-describedby="caption-attachment-5718" style="width: 1368px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5718" src="https://www.osradar.com/wp-content/uploads/2018/09/4-6.png" alt="4.- Creating the folders for virtual host" width="1368" height="747" srcset="https://www.osradar.com/wp-content/uploads/2018/09/4-6.png 1368w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-300x164.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-768x419.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-1024x559.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-696x380.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-1068x583.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/4-6-769x420.png 769w" sizes="(max-width: 1368px) 100vw, 1368px" /><figcaption id="caption-attachment-5718" class="wp-caption-text">4.- Creating the folders for the virtual hosts</figcaption></figure></p>
<p>With this in mind proceeds to change the owner of them. Run,</p>
<pre class="">:~$ sudo chown -R $USER:$USER /var/www/html/osradar1.local/public_html
:~$ sudo chown -R $USER:$USER /var/www/html/osradar2.local/public_html</pre>
<p><figure id="attachment_5719" aria-describedby="caption-attachment-5719" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5719" src="https://www.osradar.com/wp-content/uploads/2018/09/5-5.png" alt="5.- Changing the folders owner" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/5-5.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/5-5-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5719" class="wp-caption-text">5.- Changing the owner of the folders</figcaption></figure></p>
<p>Finally, change the permissions on the folders.</p>
<pre class="">:~$ sudo chmod -R 755 /var/www/html/</pre>
<p><figure id="attachment_5720" aria-describedby="caption-attachment-5720" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5720" src="https://www.osradar.com/wp-content/uploads/2018/09/6-5.png" alt="6.- Changing the permissions to the folders" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/6-5.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/6-5-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5720" class="wp-caption-text">6.- Changing the permissions to the folders</figcaption></figure></p>
<p>Now, create an example index.html file, to check the operation.</p>
<pre class="">:~$ sudo nano /var/www/html/osradar1.local/public_html/index.html
:~$ sudo nano /var/www/html/osradar2.local/public_html/index.html</pre>
<p>For the first hosts (osradar1.local) in index.html, type this:</p>
<pre class="">&lt;html&gt;
&lt;header&gt;
&lt;title&gt;
osradar1.local website
&lt;/title&gt;
&lt;/header&gt;
&lt;body&gt;
This message is from osradar1.local website
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And for the second host:</p>
<pre class="">&lt;html&gt;
&lt;header&gt;
&lt;title&gt;
osradar2.local website
&lt;/title&gt;
&lt;/header&gt;
&lt;body&gt;
This message is from osradar2.local website
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>3.- Create the configuration file for each host</h2>
<p>In this step, you must create the configuration files for each virtual host, but it&#8217;s not complicated because you can rely on the default configuration file.</p>
<p>In the first place, copy the default configuration file, and rename it for each virtual host.</p>
<pre class="">:~$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/osradar1.local.conf
:~$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/osradar2.local.conf</pre>
<p><figure id="attachment_5721" aria-describedby="caption-attachment-5721" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5721" src="https://www.osradar.com/wp-content/uploads/2018/09/7-6.png" alt="7.- Copying the apache default configuration file" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/7-6.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/7-6-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5721" class="wp-caption-text">7.- Copying the apache default configuration file</figcaption></figure></p>
<p>Now, you must edit the files to adapt them to each virtual. For example, edit <code>osradar1.local.conf</code>.</p>
<pre class="">:~$ sudo nano /etc/apache2/sites-available/osradar1.local.conf</pre>
<p>In that file, you must modify ServerName, ServerAlias, ServerAdmin, and DocumentRoot.</p>
<p><figure id="attachment_5722" aria-describedby="caption-attachment-5722" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5722" src="https://www.osradar.com/wp-content/uploads/2018/09/8-4.png" alt="8.- Editing Virtual host configuration file" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/8-4.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/8-4-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5722" class="wp-caption-text">8.- Editing Virtual host configuration file</figcaption></figure></p>
<p>Do the same for the other virtual host.</p>
<p><figure id="attachment_5723" aria-describedby="caption-attachment-5723" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5723" src="https://www.osradar.com/wp-content/uploads/2018/09/9-3.png" alt="9.- Editing the second file" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/9-3.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/9-3-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5723" class="wp-caption-text">9.- Editing the second file</figcaption></figure></p>
<h2>4. Enabling configuration files</h2>
<p>Once the configuration files are ready, you must activate them. First, disable the default configuration file and then activate the newly created virtual hosts.</p>
<pre class="">:~$ sudo a2dissite 000-default.conf
:~$ sudo a2ensite osradar1.local.conf
:~$ sudo a2ensite osradar2.local.conf</pre>
<p><figure id="attachment_5724" aria-describedby="caption-attachment-5724" style="width: 1366px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5724" src="https://www.osradar.com/wp-content/uploads/2018/09/10-3.png" alt="10.- Enabling new configuration file for the virtual hosts" width="1366" height="768" srcset="https://www.osradar.com/wp-content/uploads/2018/09/10-3.png 1366w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-300x169.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-768x432.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-1024x576.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-696x391.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-1068x600.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/10-3-747x420.png 747w" sizes="(max-width: 1366px) 100vw, 1366px" /><figcaption id="caption-attachment-5724" class="wp-caption-text">10.- Enabling new configuration file for the virtual hosts</figcaption></figure></p>
<p>And it&#8217;s ready. Now let&#8217;s check that everything was successful. Restart apache2.</p>
<pre class="">:~$ sudo systemctl restart apache2</pre>
<h2>5.- Test the virtual hosts</h2>
<p>In the first place, edit the file <code>/etc/hosts</code> and add your IP with the names of the virtual hosts.</p>
<pre class="">:~$ sudo nano /etc/hosts</pre>
<p><figure id="attachment_5726" aria-describedby="caption-attachment-5726" style="width: 573px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5726" src="https://www.osradar.com/wp-content/uploads/2018/09/11-2.png" alt="11.- Editing hosts file&lt;" width="573" height="153" srcset="https://www.osradar.com/wp-content/uploads/2018/09/11-2.png 573w, https://www.osradar.com/wp-content/uploads/2018/09/11-2-300x80.png 300w" sizes="(max-width: 573px) 100vw, 573px" /><figcaption id="caption-attachment-5726" class="wp-caption-text">11.- Editing hosts file</figcaption></figure></p>
<p>Now, go to your web browser and enter your virtual host.</p>
<p><figure id="attachment_5728" aria-describedby="caption-attachment-5728" style="width: 1131px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5728" src="https://www.osradar.com/wp-content/uploads/2018/09/12-2.png" alt="12.- Checking the virtual hosts" width="1131" height="437" srcset="https://www.osradar.com/wp-content/uploads/2018/09/12-2.png 1131w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-300x116.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-768x297.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-1024x396.png 1024w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-696x269.png 696w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-1068x413.png 1068w, https://www.osradar.com/wp-content/uploads/2018/09/12-2-1087x420.png 1087w" sizes="(max-width: 1131px) 100vw, 1131px" /><figcaption id="caption-attachment-5728" class="wp-caption-text">12.- Checking the virtual hosts</figcaption></figure></p>
<p><figure id="attachment_5729" aria-describedby="caption-attachment-5729" style="width: 890px" class="wp-caption alignnone"><img loading="lazy" class="size-full wp-image-5729" src="https://www.osradar.com/wp-content/uploads/2018/09/13.png" alt="13.- Checking virtual hosts" width="890" height="417" srcset="https://www.osradar.com/wp-content/uploads/2018/09/13.png 890w, https://www.osradar.com/wp-content/uploads/2018/09/13-300x141.png 300w, https://www.osradar.com/wp-content/uploads/2018/09/13-768x360.png 768w, https://www.osradar.com/wp-content/uploads/2018/09/13-696x326.png 696w" sizes="(max-width: 890px) 100vw, 890px" /><figcaption id="caption-attachment-5729" class="wp-caption-text">13.- Checking virtual hosts</figcaption></figure></p>
<p>And this is it. As you can see it&#8217;s really simple.</p>
<p>Tell us, how was your experience with Apache?</p>
<p>Please spread this article through your social networks.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-configure-an-apache-virtual-host-on-debian-9/">How to configure an Apache Virtual host on Debian 9?</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-configure-an-apache-virtual-host-on-debian-9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
