{"id":26,"date":"2020-12-23T19:02:32","date_gmt":"2020-12-23T19:02:32","guid":{"rendered":"http:\/\/feellikelearning.com\/en\/?p=26"},"modified":"2020-12-23T19:02:32","modified_gmt":"2020-12-23T19:02:32","slug":"how-to-set-up-multiple-websites-using-apache2","status":"publish","type":"post","link":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/","title":{"rendered":"How to set up multiple websites using apache2?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Add content for the websites<\/h2>\n\n\n\n<p>The content of the apache2 websites on Ubuntu is in<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/var\/www\/html\/<\/code><\/pre>\n\n\n\n<p>We can put the website content (php, html files) in the subdirectories of the above path, such as<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/var\/www\/html\/site1\n\/var\/www\/html\/site2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Set up Apache2<\/h2>\n\n\n\n<p>This article uses Ubuntu as an example. The files we need to edit are in<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/apache2<\/code><\/pre>\n\n\n\n<p>First, add a new site config file in sites-available directory, such as site1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/etc\/apache2\/sites-available\nvim site1.conf<\/code><\/pre>\n\n\n\n<p>The content of the site conf file is like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80>\n\t# The ServerName directive sets the request scheme, hostname and port that\n\t# the server uses to identify itself. This is used when creating\n\t# redirection URLs. In the context of virtual hosts, the ServerName\n\t# specifies what hostname must appear in the request's Host: header to\n\t# match this virtual host. For the default virtual host (this file) this\n\t# value is not decisive as it is used as a last resort host regardless.\n\t# However, you must set it for any further virtual host explicitly.\n\t#ServerName www.example.com\n\n\tServerAdmin webmaster@localhost\n\tServerName site1.com\n\tServerAlias www.site1.com\n\tDocumentRoot \/var\/www\/html\/site1\n\n\t# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n\t# error, crit, alert, emerg.\n\t# It is also possible to configure the loglevel for particular\n\t# modules, e.g.\n\t#LogLevel info ssl:warn\n\n\tErrorLog ${APACHE_LOG_DIR}\/error.log\n\tCustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n\t# For most configuration files from conf-available\/, which are\n\t# enabled or disabled at a global level, it is possible to\n\t# include a line for only one particular virtual host. For example the\n\t# following line enables the CGI configuration for this host only\n\t# after it has been globally disabled with \"a2disconf\".\n\t#Include conf-available\/serve-cgi-bin.conf\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>Then we can add conf file the second website, such as site2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/etc\/apache2\/sites-available\nvim site2.conf<\/code><\/pre>\n\n\n\n<p>Add content to site2.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80>\n\t# The ServerName directive sets the request scheme, hostname and port that\n\t# the server uses to identify itself. This is used when creating\n\t# redirection URLs. In the context of virtual hosts, the ServerName\n\t# specifies what hostname must appear in the request's Host: header to\n\t# match this virtual host. For the default virtual host (this file) this\n\t# value is not decisive as it is used as a last resort host regardless.\n\t# However, you must set it for any further virtual host explicitly.\n\t#ServerName www.example.com\n\n\tServerAdmin webmaster@localhost\n\tServerName site2.com\n\tServerAlias www.site2.com\n\tDocumentRoot \/var\/www\/html\/site2\n\n\t# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n\t# error, crit, alert, emerg.\n\t# It is also possible to configure the loglevel for particular\n\t# modules, e.g.\n\t#LogLevel info ssl:warn\n\n\tErrorLog ${APACHE_LOG_DIR}\/error.log\n\tCustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n\t# For most configuration files from conf-available\/, which are\n\t# enabled or disabled at a global level, it is possible to\n\t# include a line for only one particular virtual host. For example the\n\t# following line enables the CGI configuration for this host only\n\t# after it has been globally disabled with \"a2disconf\".\n\t#Include conf-available\/serve-cgi-bin.conf\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>Finally, we need to create symbolic links for the conf files of the above two sites and place them in sites-enabled directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ln -s \/etc\/apache2\/sites-available\/site1.conf \/etc\/apache2\/sites-enabled\/site1.conf\nln -s \/etc\/apache2\/sites-available\/site2.conf \/etc\/apache2\/sites-enabled\/site2.conf<\/code><\/pre>\n\n\n\n<p>May need to restart apache2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service apache2 restart<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Update Domain Name DNS<\/h2>\n\n\n\n<p>Take <a href=\"https:\/\/www.namecheap.com\/\">Namecheap<\/a> as an example, go to the target domain name, such as site1.com, click Manage, and then in Advanced DNS, setup is as follows<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" src=\"http:\/\/feellikelearning.com\/en\/wp-content\/uploads\/2020\/12\/blog-covers.021.jpeg\" alt=\"\" class=\"wp-image-27\"\/><\/figure>\n\n\n\n<p>Add a similar configuration for site2. Since they are on the same server and the host ip should be the same, just change site1.com to site2.com<\/p>\n\n\n\n<p>Finally, open site1.com and site2.com in the browser to verify they work as expected.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add content for the websites The content of the apache2 websites on Ubuntu is in We can put the website content (php, html files) in the subdirectories of the above path, such as Set up Apache2 This article uses Ubuntu as an example. The files we need to edit are in First, add a new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":29,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,5],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache2","category-coding"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to set up multiple websites using apache2? - Feel Like Learning<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set up multiple websites using apache2? - Feel Like Learning\" \/>\n<meta property=\"og:description\" content=\"Add content for the websites The content of the apache2 websites on Ubuntu is in We can put the website content (php, html files) in the subdirectories of the above path, such as Set up Apache2 This article uses Ubuntu as an example. The files we need to edit are in First, add a new [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/\" \/>\n<meta property=\"og:site_name\" content=\"Feel Like Learning\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-23T19:02:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/feellikelearning.com\/en\/wp-content\/uploads\/2020\/12\/blog-covers.023.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"feellikelearning\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"feellikelearning\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/\",\"url\":\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/\",\"name\":\"How to set up multiple websites using apache2? - Feel Like Learning\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/#website\"},\"datePublished\":\"2020-12-23T19:02:32+00:00\",\"dateModified\":\"2020-12-23T19:02:32+00:00\",\"author\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7\"},\"breadcrumb\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/feellikelearning.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to set up multiple websites using apache2?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#website\",\"url\":\"https:\/\/feellikelearning.com\/en\/\",\"name\":\"Feel Like Learning\",\"description\":\"keep curiosity alive\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/feellikelearning.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7\",\"name\":\"feellikelearning\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g\",\"caption\":\"feellikelearning\"},\"sameAs\":[\"http:\/\/feellikelearning.com\/en\"],\"url\":\"https:\/\/feellikelearning.com\/en\/index.php\/author\/feellikelearning\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set up multiple websites using apache2? - Feel Like Learning","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/","og_locale":"en_US","og_type":"article","og_title":"How to set up multiple websites using apache2? - Feel Like Learning","og_description":"Add content for the websites The content of the apache2 websites on Ubuntu is in We can put the website content (php, html files) in the subdirectories of the above path, such as Set up Apache2 This article uses Ubuntu as an example. The files we need to edit are in First, add a new [&hellip;]","og_url":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/","og_site_name":"Feel Like Learning","article_published_time":"2020-12-23T19:02:32+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/feellikelearning.com\/en\/wp-content\/uploads\/2020\/12\/blog-covers.023.jpeg","type":"image\/jpeg"}],"author":"feellikelearning","twitter_card":"summary_large_image","twitter_misc":{"Written by":"feellikelearning","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/","url":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/","name":"How to set up multiple websites using apache2? - Feel Like Learning","isPartOf":{"@id":"https:\/\/feellikelearning.com\/en\/#website"},"datePublished":"2020-12-23T19:02:32+00:00","dateModified":"2020-12-23T19:02:32+00:00","author":{"@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7"},"breadcrumb":{"@id":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/feellikelearning.com\/en\/index.php\/2020\/12\/23\/how-to-set-up-multiple-websites-using-apache2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/feellikelearning.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to set up multiple websites using apache2?"}]},{"@type":"WebSite","@id":"https:\/\/feellikelearning.com\/en\/#website","url":"https:\/\/feellikelearning.com\/en\/","name":"Feel Like Learning","description":"keep curiosity alive","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/feellikelearning.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7","name":"feellikelearning","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g","caption":"feellikelearning"},"sameAs":["http:\/\/feellikelearning.com\/en"],"url":"https:\/\/feellikelearning.com\/en\/index.php\/author\/feellikelearning\/"}]}},"_links":{"self":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":1,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":28,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions\/28"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/media\/29"}],"wp:attachment":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}