{"id":667,"date":"2019-06-19T18:12:57","date_gmt":"2019-06-19T18:12:57","guid":{"rendered":"http:\/\/dev.local\/?page_id=667"},"modified":"2020-01-07T02:48:35","modified_gmt":"2020-01-07T02:48:35","slug":"removing-an-apaches-virtual-host","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=667","title":{"rendered":"Removing an Apache&#8217;s Virtual Host"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">Step One &#8211; Deleting DNS entries <\/h2>\n\n\n\n<p>The first step you must complete when removing an Apache&#8217;s Virtual Host is to delete the DNS entries, that way your website will no longer be reachable through its URL.<\/p>\n\n\n\n<p>This step is absolutely necessary for an organized removal of your Apaches&#8217;s Virtual Host, if you don&#8217;t complete this step first, then the people trying to access your website will get the most weird and unexpected error messages, of course you don&#8217;t want that to happen to your visitors.<\/p>\n\n\n\n<p>Even if the files and folders belonging to your website are still on your web server, immediately after the DNS entries are deleted, you can rest assured that nobody will hit your website anymore.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Deleting Digital Ocean DNS entries<\/h3>\n\n\n\n<p>The following procedure can be followed by those of you who are using Digital Ocean (DO) to host your websites, most probably through one of the well known DO Droplets (VPS).<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1 &#8211; Login into your DO account and select your Droplet<\/li><li>2 &#8211; Go to Networking\/Domains and select your Domain<\/li><li>3 &#8211; Remove first the &#8220;A&#8221; record<\/li><li>4 &#8211; Remove the matching &#8220;CNAME&#8221; record<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-removal-confirmation.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"294\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-removal-confirmation.jpg\" alt=\"\" class=\"wp-image-739\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-removal-confirmation.jpg 531w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-removal-confirmation-300x166.jpg 300w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/a><figcaption>Deletion confirmation<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-a-record-removal-confirmation.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-a-record-removal-confirmation.jpg\" alt=\"\" class=\"wp-image-740\" width=\"517\" height=\"217\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-a-record-removal-confirmation.jpg 517w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-a-record-removal-confirmation-300x126.jpg 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><figcaption>A record has been deleted<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-cname-removal-confirmation.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"197\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-cname-removal-confirmation.jpg\" alt=\"CNAME record has been deleted\" class=\"wp-image-741\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-cname-removal-confirmation.jpg 502w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/digital-ocean-cname-removal-confirmation-300x118.jpg 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><figcaption>CNAME record has been deleted<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step two &#8211; Deleting Virtual Host file<\/h2>\n\n\n\n<p>As you probably know, deleting the DNS entries doesn&#8217;t stop people (the most tech savvy) to reach your Apache&#8217;s Virtual Host if they know the IP Address of your server (VPS).<\/p>\n\n\n\n<p>That is because Apache still has an entry for your Virtual Host and will send any request coming via the IP Address to the matching Virtual Host, that&#8217;s why the next step is then, to delete the Virtual Host file and reload Apache to allow it to recognize this change.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Finding the right Virtual Host file<\/h3>\n\n\n\n<p>Use the following image of the <strong>Linux directory tree<\/strong> (folders) to see where the Virtual Host files are located, and if you need the path for <strong>CentOS 7<\/strong>, here you are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">\/etc\/httpd\/conf.d\/<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/linux-directory-tree-apache-virtual-host-file-v6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/linux-directory-tree-apache-virtual-host-file-v6.png\" alt=\"linux directory tree apache virtual host file\" class=\"wp-image-970\" width=\"660\" height=\"407\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/linux-directory-tree-apache-virtual-host-file-v6.png 880w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/linux-directory-tree-apache-virtual-host-file-v6-300x185.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/linux-directory-tree-apache-virtual-host-file-v6-768x474.png 768w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><figcaption>Apache Virtual Hosts files<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Example of a typical Virtual Host file<\/h3>\n\n\n\n<p>Just in case you want to double check that what you are doing is the right thing here you can see an screenshot of a typical Virtual Host file, as you can see it is just an small text file.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-virtual-host-sample.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-virtual-host-sample.jpg\" alt=\"\" class=\"wp-image-747\" width=\"598\" height=\"359\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-virtual-host-sample.jpg 598w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-virtual-host-sample-300x180.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/a><figcaption>Example of a typical Virtual Host file<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Deleting the Virtual Host file<\/h3>\n\n\n\n<p>Depending on your preferences, once you&#8217;ve identified the Virtual Host file you want to delete, just remove it either via the CLI using the &#8220;rm&#8221; command or using the GUI provided by WinSCP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">rm virtual-host-01.conf<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong> Remember that when you are removing a file you don&#8217;t have to add any argument to the &#8220;<strong>rm<\/strong>&#8221; command.<\/p>\n\n\n\n<p>The follow screenshot shows how to delete a file using WinSCP<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/delete-file-with-winscp-01.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/delete-file-with-winscp-01.jpg\" alt=\"\" class=\"wp-image-718\" width=\"646\" height=\"473\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/delete-file-with-winscp-01.jpg 646w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/delete-file-with-winscp-01-300x220.jpg 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/a><figcaption>Deleting a file using WinSCP<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step three &#8211; Restart Apache<\/h2>\n\n\n\n<p>Restarting Apache is a task that you&#8217;ll get used to more sooner than later, because most of the tasks involving Apache&#8217;s files and directories require to restart it, here the CLI command you are going to need for CentOS 7.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl restart httpd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step four &#8211; verify Apache status <\/h2>\n\n\n\n<p>Checking or verifying that Apache is back on its feet could be considered an optional task, but in my opinion it&#8217;s always at your best interest to make sure the changes you made didn&#8217;t affected the normal execution of your web server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl status httpd.service<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-status-centos7.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-status-centos7.jpg\" alt=\"\" class=\"wp-image-721\" width=\"944\" height=\"451\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-status-centos7.jpg 944w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-status-centos7-300x143.jpg 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/06\/apache-status-centos7-768x367.jpg 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>checking Apache status<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step five &#8211; Remove Virtual Host files<\/h2>\n\n\n\n<p>This step can be considered optional if you don&#8217;t mind having some files and folders that are not really being used, it&#8217;s going to be kind of backup of your website.<br>The truth is that most of the times people just prefer to remove all these files and folders to have a clean OS and save some disk space at the same time, it is totally up to you.<\/p>\n\n\n\n<p>If you were using SSL certificates for your Virtual Host then, also optional, do find them on your server and delete them too.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step six &#8211; Delete WordPress Data Base<\/h2>\n\n\n\n<p>If your website was running on WordPress, then there is an additional step for you, I&#8217;m talking about deleting the WordPress Data Base, that task can be done either via the CLI or if you prefer the GUI fashion then you can count with <strong>PHP MyAdmin<\/strong> for this task.<\/p>\n\n\n\n<p>As you can imagine, Data Bases are the main processor and memory consumers so this step shouldn&#8217;t be optional because every time you are removing an Apache&#8217;s Virtual Host you&#8217;ll want to get back as much resources as possible to improve the performance of your server.<\/p>\n\n\n\n<p>We&#8217;re going to use phpMyAdmin to delete the Data Base because its GUI makes this task a lot easy.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01.jpg\"><figure><figure><img loading=\"lazy\" decoding=\"async\" width=\"1262\" height=\"425\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01.jpg\" alt=\"\" class=\"wp-image-1532\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01.jpg 1262w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01-300x101.jpg 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01-1024x345.jpg 1024w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-01-768x259.jpg 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure><\/figure><figcaption>phpMyAdmin &#8211; DROP database<\/figcaption><\/a><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-02.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"354\" height=\"196\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-02.jpg\" alt=\"\" class=\"wp-image-1536\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-02.jpg 354w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-02-300x166.jpg 300w\" sizes=\"auto, (max-width: 354px) 100vw, 354px\" \/><\/a><figcaption>phpMyAdmin database deletion confirmation<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-03.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"401\" height=\"121\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-03.jpg\" alt=\"\" class=\"wp-image-1537\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-03.jpg 401w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/phpMyAdmin-deleting-db-03-300x91.jpg 300w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/a><figcaption>phpMyAdmin database deletion completed<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>Ok, we&#8217;ve covered a bunch of things here, I didn&#8217;t went deep really, that was never my intention, instead what I wanted to have was a sort of check list to be used when removing an Apache&#8217;s Virtual Host.<\/p>\n\n\n\n<p>I hope you&#8217;ve find this article useful, please don&#8217;t hesitate to contact us if you have any question and\/or suggestion.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step One &#8211; Deleting DNS entries The first step you must complete when removing an Apache&#8217;s Virtual Host is to delete the DNS entries, that way your website will no longer be reachable through its URL. This step is absolutely necessary for an organized removal of your Apaches&#8217;s Virtual Host, if you don&#8217;t complete this &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=667\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Removing an Apache&#8217;s Virtual Host&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-667","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=667"}],"version-history":[{"count":88,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/667\/revisions"}],"predecessor-version":[{"id":1568,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/667\/revisions\/1568"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}