{"id":1030,"date":"2019-08-10T18:41:26","date_gmt":"2019-08-10T18:41:26","guid":{"rendered":"http:\/\/dev.local\/?page_id=1030"},"modified":"2020-05-07T17:46:11","modified_gmt":"2020-05-07T17:46:11","slug":"apache-virtual-host-index-html","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=1030","title":{"rendered":"Apache Virtual Host index.html"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">The HTML code of a simple webpage <\/h2>\n\n\n\n<p>In order to be able to test our Apache&#8217;s Virtual Host, we&#8217;re going to need a simple web page, the simplest one, see the following screenshot:<\/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\/08\/apache-index.html-example.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-index.html-example.png\" alt=\"\" class=\"wp-image-1044\" width=\"561\" height=\"263\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-index.html-example.png 561w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-index.html-example-300x141.png 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">A simple webpage as seen by visitors<\/h2>\n\n\n\n<p>Once all the configuration is done the html code will be recognized and the browser will show the following web page.<\/p>\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\/index-html-test-ok.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"490\" height=\"194\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/index-html-test-ok.jpg\" alt=\"\" class=\"wp-image-1560\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/index-html-test-ok.jpg 490w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/01\/index-html-test-ok-300x119.jpg 300w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Just in case, if you need the &#8220;<strong>index.html<\/strong>&#8221; file, you can download it from <a href=\"\/download\/index.html.zip\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copy the HTML code<\/h2>\n\n\n\n<p>If you want to copy the HTML code and create the file using a text editor, let&#8217;s say &#8220;<a href=\"\/vi-and-vim\/\">vi<\/a>&#8220;, then here you are the code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"markup\" class=\"language-markup\">&lt;!DOCTYPE html>\n&lt;html lang=\"en\">\n  &lt;head>\n    &lt;meta charset=\"utf-8\">\n    &lt;title>Welcome to My site&lt;\/title>\n  &lt;\/head>\n  &lt;body>\n    &lt;h1>Success! My site home page!&lt;\/h1>\n  &lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create index.html using the Tee command<\/h2>\n\n\n\n<p>From the CLI you can save time and effort when creating the &#8220;index.html&#8221; file, you don&#8217;t have to open a text editor, paste the code, and save it to then be ready to upload it to the root folder of your website, using the Tee command we&#8217;re going to do all these tasks in only one simple step, just copy the following command and paste into the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">tee \/var\/www\/subdomain.example.com\/public_html\/index.html&lt;&lt;EOF\n&lt;!DOCTYPE html>\n&lt;html lang=\"en\">\n  &lt;head>\n    &lt;meta charset=\"utf-8\">\n    &lt;title>Welcome to My site&lt;\/title>\n  &lt;\/head>\n  &lt;body>\n    &lt;h1>Success! My site home page!&lt;\/h1>\n  &lt;\/body>\n&lt;\/html> \nEOF<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/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\/05\/Apache-crating-index.html-using-the-Tee-command-00.png\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"459\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-00.png\" alt=\"\" class=\"wp-image-5284\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-00.png 801w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-00-300x172.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-00-768x440.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>Tee command in action<\/figcaption><\/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\/05\/Apache-crating-index.html-using-the-Tee-command-01.png\"><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"117\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-01.png\" alt=\"\" class=\"wp-image-5285\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-01.png 585w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/05\/Apache-crating-index.html-using-the-Tee-command-01-300x60.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><figcaption>index.html file was successfully created<\/figcaption><\/figure><\/div>\n\n\n\n<p>The <strong>index.html<\/strong> file is just an example, a test file, once Apache recognizes it you can be absolutely sure that you are ready to start building your website either from the scratch using programming languages like HTML, JavaScript, CSS, PHP, etc. or taking advantage of one of the multiple CMS (Content Management Systems) available these days, a good example of one of them, and by the way the most commonly used would be &#8220;<a href=\"\/wordpress-2\/\">WordPress<\/a>&#8220;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ownership and permissions<\/h2>\n\n\n\n<p>Now that we have the directories and also the &#8220;index.html&#8221; file in place, we can take care of the Ownership and Permissions, as you can imagine both, files and folders, have to be prepared for Apache to be able to read them and show them to visitors.<\/p>\n\n\n\n<p>We can accomplish that task either using the CLI or using WinSCP, let&#8217;s see how it is done using the GUI provided by WinSCP.<\/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\/08\/apache-owner-and-permissions-01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-01.png\" alt=\"\" class=\"wp-image-1058\" width=\"644\" height=\"322\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-01.png 858w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-01-300x150.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-01-768x384.png 768w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Both Owner and Group must be changed to &#8220;Apache&#8221;, see screenshot below:<\/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\/08\/apache-owner-and-permissions-04-both.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-04-both.png\" alt=\"\" class=\"wp-image-1059\" width=\"655\" height=\"430\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-04-both.png 873w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-04-both-300x197.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-owner-and-permissions-04-both-768x504.png 768w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Be sure to put the check in the checkbox located at the bottom, where it says that owner and permissions will be set <strong>recursively<\/strong>, that means that not only the current folder will be configured but also sub-folders and files inside them, all at once.<\/p>\n\n\n\n<p>When it comes to &#8220;<strong>Permissions<\/strong>&#8221; as you can see in the above screenshot only &#8220;the owner&#8221;, in this particular case, &#8220;only Apache&#8221; will be able to Read, Write, and Execute the files, while both the group and others, they will be able to Read and Execute but not to Write (modify) the files, this configuration is represented by the Octal <strong>0755<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> Apache isn&#8217;t in the drop down list <\/h2>\n\n\n\n<p>If you are configuring the Ownership via WinSCP for the first time you won&#8217;t see Apache in the drop down list, in this case you must change it via the CLI using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">chown -R apache:apache \/var\/www\/*<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Apache Config Test<\/h2>\n\n\n\n<p>Let&#8217;s see if the changes we&#8217;ve made so far have been recognized by our Apache and if so we&#8217;d like to know that everything is fine, and for that purpose we can use the following CLI command.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>apachectl configtest<\/strong><\/li><\/ul>\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\/apache-configtest-syntax-ok-v2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-configtest-syntax-ok-v2.png\" alt=\"\" class=\"wp-image-1500\" width=\"776\" height=\"133\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-configtest-syntax-ok-v2.png 776w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-configtest-syntax-ok-v2-300x51.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/apache-configtest-syntax-ok-v2-768x132.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>If the outcome of the &#8220;<strong>apachectl configtest<\/strong>&#8221; command is &#8220;<strong>Syntax OK<\/strong>&#8221; you are good to go.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Restart Apache<\/h2>\n\n\n\n<p>Now that we know our changes do not affect Apache we can do a restart and then check the status.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>systemctl restart httpd.service<\/strong><\/li><li> <strong>systemctl status httpd.service<\/strong> <\/li><\/ul>\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\/systemctl-status-httpd-service.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/systemctl-status-httpd-service.png\" alt=\"\" class=\"wp-image-1505\" width=\"757\" height=\"429\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/systemctl-status-httpd-service.png 1009w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/systemctl-status-httpd-service-300x170.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/systemctl-status-httpd-service-768x435.png 768w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Where to go from here?<\/h2>\n\n\n\n<p>Now that we have folders and files in place and the ownership and permissions have been configured, we can start working with the Domain name, here we have two possibilities, those of you working on a LAB environment can use the &#8220;hosts&#8221; file to add a new local domain name, or those of you working on a real life scenario can go to Digital Ocean (or your preferred hosting provider) to configure the DNS entries there.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>LAB scenario &#8211; <a href=\"\/windows-hosts-file-vs-dns\/\">add local domain into the hosts file<\/a><\/li><li>Production scenario &#8211; <a href=\"\/digital-ocean-domain-settings\/\">Digital Ocean domain settings<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The HTML code of a simple webpage In order to be able to test our Apache&#8217;s Virtual Host, we&#8217;re going to need a simple web page, the simplest one, see the following screenshot: A simple webpage as seen by visitors Once all the configuration is done the html code will be recognized and the browser &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=1030\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Apache Virtual Host index.html&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1030","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/1030","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1030"}],"version-history":[{"count":72,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/1030\/revisions"}],"predecessor-version":[{"id":5297,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/1030\/revisions\/5297"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}