{"id":1900,"date":"2019-02-27T13:00:03","date_gmt":"2019-02-27T13:00:03","guid":{"rendered":"http:\/\/chewett.co.uk\/blog\/?p=1900"},"modified":"2019-02-26T23:30:32","modified_gmt":"2019-02-26T23:30:32","slug":"adding-a-virtual-host-in-apache","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/1900\/adding-a-virtual-host-in-apache\/","title":{"rendered":"Adding a Virtual Host in Apache"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"254\" data-attachment-id=\"2034\" data-permalink=\"https:\/\/chewett.co.uk\/blog\/1900\/adding-a-virtual-host-in-apache\/virtual_hosts_with_apache\/\" data-orig-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?fit=800%2C300&amp;ssl=1\" data-orig-size=\"800,300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"virtual_hosts_with_apache\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?fit=300%2C113&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?fit=678%2C254&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?resize=678%2C254&#038;ssl=1\" alt=\"\" class=\"wp-image-2034\" srcset=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?resize=300%2C113&amp;ssl=1 300w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?resize=768%2C288&amp;ssl=1 768w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_hosts_with_apache.jpg?resize=50%2C19&amp;ssl=1 50w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\n\n\n\n<p>This post includes a short snippet and some explanation about how you can use Virtual Hosts with Apache.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Why use a Virtual Host<\/h2>\n\n\n\n<p>To run multiple sites with a single Apache install you can use Virtual Hosts.<\/p>\n\n\n\n<p>This is a feature where Apache will load different webserver configurations depending on the hostname that is requested. To configure this you can add a Virtual Host in the Apache vhosts file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to add a Virtual Host<\/h2>\n\n\n\n<p>By default Apache normally includes a <code>sites.conf<\/code> or <code>httpd-vhosts.conf<\/code> file which you would place the virtual host data in.<\/p>\n\n\n\n<p>An example virtual host entry is below.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;VirtualHost testing.local:80&gt;\n    ServerAdmin email@email.com\n    DocumentRoot &quot;C:\/www\/testing_local_website\/&quot;\n    ServerName testing.local\n    ServerAlias www.testing.local\n    ErrorLog &quot;logs\/testing.local-error.log&quot;\n    CustomLog &quot;logs\/testing.local-access.log&quot; common\n&amp;lt;\/VirtualHost&gt;\n<\/pre><\/div>\n\n\n<p>Here the first line of the tag defines what hostname and port will be matched for this entry. Instead of defining a hostname you can use * to match any hostnames for the given port.<\/p>\n\n\n\n<p>The entries inside this VirtualHost tag are mostly optional but define your new website. Any requests for <code>testing.local<\/code> at your webserver on port 80 will trigger this virtual host and be loaded.<\/p>\n\n\n\n<p>Here I define a few tags:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>ServerAdmin &#8211; An email address that will be used by your server. This is sometimes printed when there is an error.<\/li><li>DocumentRoot &#8211; The location of the files for this host. These files will be served when the user loads the site.<\/li><li>ServerName &#8211; The name of the server this Virtual Host is hosting.<\/li><li>ServerAlias &#8211; You may specify a number of additional server aliases. In this case www.testing.local is also defined as an alias.<\/li><li>ErrorLog &#8211; This configures the error logs to be output to a custom Virtual Host specific log file.<\/li><li>CustomLog &#8211;  This configures a custom logger to be output to a custom Virtual Host specific log file. <\/li><\/ul>\n\n\n\n<p>Once added, you will just need to reboot your webserver and it will be ready to use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post includes a short snippet and some explanation about how you can use Virtual Hosts with Apache.<\/p>\n","protected":false},"author":1,"featured_media":2035,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Today I talk about adding a Virtual Host in #Apache","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[68,331,330],"class_list":["post-1900","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-informational","tag-apache","tag-virtual-host","tag-websever"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/virtual_host_with_apache.jpg?fit=800%2C800&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-uE","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":490,"url":"https:\/\/chewett.co.uk\/blog\/490\/setting-ssl-certbot-apache-fedora\/","url_meta":{"origin":1900,"position":0},"title":"Setting up SSL with certbot with Apache and Fedora","author":"Chewett","date":"August 16, 2017","format":false,"excerpt":"This post describes how to set \u00a0up a SSL certificate with Certbot on Apache and Fedora. The guide primarily follows the guide on the certbot website however adds some additional information for if auto configuration fails. Running Certbot on Fedora On Fedora running certbot is relatively easy as it is\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/ssl_with_apache_fedora_and_certbot.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/ssl_with_apache_fedora_and_certbot.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/ssl_with_apache_fedora_and_certbot.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/ssl_with_apache_fedora_and_certbot.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1911,"url":"https:\/\/chewett.co.uk\/blog\/1911\/uninstall-apache-as-a-service-on-windows\/","url_meta":{"origin":1900,"position":1},"title":"Uninstall Apache as a Service on Windows","author":"Chewett","date":"February 9, 2019","format":false,"excerpt":"Today I share how you can uninstall the Apache Windows service. Why uninstall the Apache Service If you want to reinstall Apache you will want to remove the service first. This ensures you will be able to fully uninstall apache before reinstall. In other situations you might want to reinstall\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/uninstall_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/uninstall_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/uninstall_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/uninstall_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1908,"url":"https:\/\/chewett.co.uk\/blog\/1908\/install-apache-as-a-service-on-windows\/","url_meta":{"origin":1900,"position":2},"title":"Install Apache as a Service on Windows","author":"Chewett","date":"January 26, 2019","format":false,"excerpt":"Today I share how you can install the Apache webserver as a Windows service. Why install Apache as a service? By installing Apache as a service you are able to have it start automatically on boot. In addition to this, running Apache as a windows service allows you to easily\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/install_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/install_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/install_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/01\/install_apache_windows_service.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":982,"url":"https:\/\/chewett.co.uk\/blog\/982\/fixing-letsencrypt-validation-failed-selected-authenticator-not-support-combination-challenges\/","url_meta":{"origin":1900,"position":3},"title":"Fixing Letsencrypt validation failed with selected authenticator does not support any combination of challenges","author":"Chewett","date":"January 31, 2018","format":false,"excerpt":"This post goes through the steps of fixing Letsencrypt with the issue \"Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA.\". Why Letsencrypt fails to validate domains When trying to set up a new https website with Letsencrypt you may get\u2026","rel":"","context":"In &quot;Fixes&quot;","block_context":{"text":"Fixes","link":"https:\/\/chewett.co.uk\/blog\/category\/fixes\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/01\/fixing_letsencrypt_fedora.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/01\/fixing_letsencrypt_fedora.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/01\/fixing_letsencrypt_fedora.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/01\/fixing_letsencrypt_fedora.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":148,"url":"https:\/\/chewett.co.uk\/blog\/148\/location-geoip-dat-php\/","url_meta":{"origin":1900,"position":4},"title":"Location of GeoIP.dat for PHP","author":"Chewett","date":"September 1, 2013","format":false,"excerpt":"To find the location of GeoIP for PHP you can ssh into the server and use the \"find\" command. find \/ -iname GeoIP.dat Will return a list of file paths where the file with this name is found. In my case I found: \/usr\/share\/GeoIP\/GeoIP.dat \/usr\/local\/share\/GeoIP\/GeoIP.dat \/opt\/geoip\/share\/GeoIP\/GeoIP.dat In my case the\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":82,"url":"https:\/\/chewett.co.uk\/blog\/82\/raspberry-pi\/","url_meta":{"origin":1900,"position":5},"title":"Raspberry Pi!","author":"Chewett","date":"January 22, 2013","format":false,"excerpt":"During Christmas I got a raspberry pi and I have been waiting to start playing around with it for ages. Finally I decided to order the remaining pieces for it such as the power cable and SD card. Since I didn't have a HDMI TV around I decided to plug\u2026","rel":"","context":"In \"Linux\"","block_context":{"text":"Linux","link":"https:\/\/chewett.co.uk\/blog\/tag\/linux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1900"}],"version-history":[{"count":4,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1900\/revisions"}],"predecessor-version":[{"id":2036,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1900\/revisions\/2036"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/2035"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}