{"id":1505,"date":"2020-08-28T06:47:24","date_gmt":"2020-08-28T06:47:24","guid":{"rendered":"http:\/\/ubiq.co\/tech-blog\/?p=1505"},"modified":"2025-12-23T05:50:03","modified_gmt":"2025-12-23T05:50:03","slug":"setup-nginx-virtual-hosts-centos","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/","title":{"rendered":"How to Setup NGINX Virtual Hosts on CentOS"},"content":{"rendered":"<p>Often website administrators need to host and manage several websites on a single NGINX instance. <a href=\"https:\/\/ubiq.co\/tech-blog\/configure-multiple-host-names-nginx\/\">Virtual hosts<\/a> allow you to host multiple websites and domains from single web server. It saves time and money to run multiple websites from a single machine instead of deploying separate servers for each domain. In fact, virtual hosts can also be used to run separate subdomains of a website. In this article, we will learn how to setup NGINX virtual hosts on CentOS.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#How_to_Setup_NGINX_Virtual_Hosts_on_CentOS\" >How to Setup NGINX Virtual Hosts on CentOS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#1_Create_Directories\" >1. Create Directories<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#2_Change_File_Ownership\" >2. Change File Ownership<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#3_Grant_Required_Permission\" >3. Grant Required Permission<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#4_Create_Virtual_Host_Configuration_files\" >4. Create Virtual Host Configuration files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#5_Create_HTML_pages\" >5. Create HTML pages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#6_Enable_Virtual_Hosts\" >6. Enable Virtual Hosts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#7_RestartReload_NGINX_Server\" >7. Restart\/Reload NGINX Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#8_Test_Virtual_Hosts\" >8. Test Virtual Hosts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Setup_NGINX_Virtual_Hosts_on_CentOS\"><\/span>How to Setup NGINX Virtual Hosts on CentOS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here are the steps to setup NGINX virtual hosts on CentOS. Please make sure you have installed NGINX in CentOS before you proceed further.<\/p>\n<p>In this article, we will create two virtual hosts for domains <em>domain1.com<\/em> and <em>domain2.com<\/em><\/p>\n<h2><span class=\"ez-toc-section\" id=\"1_Create_Directories\"><\/span>1. Create Directories<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Each website will obviously have separate directory to store its files and data. Since \/var\/www is the root directory of NGINX, we will need to create separate sub directories in it, one for each domain. Open terminal and create 2 directories, one for each virtual host, at \/var\/www. We will place our website files in these 2 directories.<\/p>\n<pre># sudo mkdir -p \/var\/www\/domain1.com\/html\n# sudo mkdir -p \/var\/www\/domain2.com\/html\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"2_Change_File_Ownership\"><\/span>2. Change File Ownership<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Every process needs a system user to be able to access required files and directories. It is important to allow the NGINX server to use a system user for this purpose. Run the following commands to change the ownership of these new directories to the present logged in user.<\/p>\n<pre># sudo chown -R $USER:$USER \/var\/www\/domain1.com\/html\n# sudo chown -R $USER:$USER \/var\/www\/domain2.com\/html<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"3_Grant_Required_Permission\"><\/span>3. Grant Required Permission<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We also need to grant NGINX the required permission for accessing files in \/var\/www directory.<\/p>\n<pre># sudo chmod -R 755 \/var\/www<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"4_Create_Virtual_Host_Configuration_files\"><\/span>4. Create Virtual Host Configuration files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Next, create 2 virtual host configuration files, one for each domain, at \/etc\/nginx\/sites-available<\/p>\n<p>First, create virtual host configuration file for domain1.com domain<\/p>\n<pre># sudo vim \/etc\/nginx\/sites-available\/domain1.com.conf<\/pre>\n<p>The above command will open a new file in a text editor. Add the following basic configuration in this file.<\/p>\n<pre>server {\n   listen 80;\n   listen [::]:80;\n   server_name domain1.com;\n   root \/var\/www\/domain1.com\/html;\n   index index.html;\n   location \/ {\n    try_files $uri $uri\/ =404;\n   }\n}\n<\/pre>\n<p>In the above commands we define a server block for domain1.com that listens to port 80 and serves content located at <em>\/var\/www\/domain1.com\/html<\/em><\/p>\n<p>Similarly, create virtual host configuration file for domain2.com domain<\/p>\n<pre># sudo vim \/etc\/nginx\/sites-available\/domain2.com.conf<\/pre>\n<p>The above command will open a new file in a text editor. Add the following basic configuration in this file.<\/p>\n<pre>server {\n   listen 80;\n   listen [::]:80;\n   server_name domain2.com;\n   root \/var\/www\/domain2.com\/html;\n   index index.html;\n   location \/ {\n    try_files $uri $uri\/ =404;\n   }\n}\n<\/pre>\n<p>In the above commands we define a server block for domain2.com that listens to port 80 and serves content located at <em>\/var\/www\/domain2.com\/html<\/em><\/p>\n<h2><span class=\"ez-toc-section\" id=\"5_Create_HTML_pages\"><\/span>5. Create HTML pages<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Next, create sample index.html pages for both domain. They will act as the home pages for each domain. After complete configuration, when you to try to access these domains, you will see the following HTML pages. Create index.html file for domain1.com in a text editor<\/p>\n<pre># sudo vim \/var\/www\/domain1.com\/html\/index.html\n<\/pre>\n<p>Add the following HTML:<\/p>\n<pre>&lt;html&gt;\n   &lt;head&gt;\n    &lt;title&gt;Welcome to Domain1.com!&lt;\/title&gt;\n   &lt;\/head&gt;\n   &lt;body&gt;\n   &lt;h1&gt;Success! The Domain1.com NGINX Virtual Host is working!&lt;\/h1&gt;\n   &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Similarly, create index.html file for domain2.com<\/p>\n<pre># sudo vim \/var\/www\/domain2.com\/html\/index.html\n<\/pre>\n<p>Add the following HTML:<\/p>\n<pre>&lt;html&gt;\n   &lt;head&gt;\n    &lt;title&gt;Welcome to Domain2.com!&lt;\/title&gt;\n   &lt;\/head&gt;\n   &lt;body&gt;\n    &lt;h1&gt;Success! The Domain2.com NGINX Virtual Host is working!&lt;\/h1&gt;\n   &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Bonus Read : <a href=\"http:\/\/ubiq.co\/tech-blog\/fix-503-service-temporarily-unavailable-error-nginx\/\">How to Fix 503 Service Temporarily Unavailable in NGINX<\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"6_Enable_Virtual_Hosts\"><\/span>6. Enable Virtual Hosts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Enable virtual hosts by adding symbolic links between the files present at \/etc\/nginx\/sites-available and \/etc\/nginx\/sites-enabled.<\/p>\n<pre># sudo ln -s \/etc\/nginx\/sites-available\/domain1.com.conf \/etc\/nginx\/sites-enabled\/domain1.com.conf\n# sudo ln -s \/etc\/nginx\/sites-available\/domain2.com.conf \/etc\/nginx\/sites-enabled\/domain2.com.conf\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7_RestartReload_NGINX_Server\"><\/span>7. Restart\/Reload NGINX Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Restart\/Reload NGINX server to apply changes.<\/p>\n<pre># sudo nginx -s reload\n<\/pre>\n<p>OR<\/p>\n<pre># sudo service nginx restart\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"8_Test_Virtual_Hosts\"><\/span>8. Test Virtual Hosts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Open browser and enter <em>http:\/\/domain1.com<\/em> and <em>http:\/\/domain2.com<\/em> one by one<em>.<\/em> You will see the index pages of both domains respectively.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this article, we have learnt how to setup virtual hosts for NGINX server. You can use these steps to configure virtual hosts for multiple domains and subdomains on a single server. As much as possible, try to run multiple sites on a single server since they are easy to maintain and cost effective. Hopefully, now you can easily setup NGINX virtual hosts on Ubuntu.<\/p>\n<p><a href=\"http:\/\/ubiq.co\/\">Ubiq<\/a>\u00a0makes it easy to visualize data in minutes, and monitor in real-time dashboards.\u00a0<a href=\"http:\/\/ubiq.co\/accounts\/register\">Try it<\/a> today!<\/p>\n<p>Also read:<br \/>\n<a href=\"https:\/\/ubiq.co\/tech-blog\/fix-503-service-temporarily-unavailable-error-nginx\/\">How to Fix 503 Service Unavailable Error in NGINX<\/a><br \/>\n<a href=\"https:\/\/ubiq.co\/tech-blog\/fix-500-internal-server-error-nginx\/\">How to Fix 500 Internal Server Error in NGINX<\/a><br \/>\n<a href=\"https:\/\/ubiq.co\/tech-blog\/wp-admin\/post.php?post=1284&amp;action=edit\">How to Fix 504 Gateway Timeout Error in NGINX<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here&#8217;s how to setup NGINX virtual hosts on CentOS.<\/p>\n","protected":false},"author":1,"featured_media":1511,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[124],"class_list":["post-1505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-virtual-hosts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI<\/title>\n<meta name=\"description\" content=\"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here&#039;s how to setup NGINX virtual hosts on CentOS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here&#039;s how to setup NGINX virtual hosts on CentOS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-28T06:47:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-23T05:50:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"939\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\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\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Setup NGINX Virtual Hosts on CentOS\",\"datePublished\":\"2020-08-28T06:47:24+00:00\",\"dateModified\":\"2025-12-23T05:50:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/\"},\"wordCount\":644,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1\",\"keywords\":[\"virtual hosts\"],\"articleSection\":[\"Nginx\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/\",\"name\":\"How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1\",\"datePublished\":\"2020-08-28T06:47:24+00:00\",\"dateModified\":\"2025-12-23T05:50:03+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here's how to setup NGINX virtual hosts on CentOS.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1\",\"width\":1200,\"height\":939,\"caption\":\"nginx virtual hosts\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/setup-nginx-virtual-hosts-centos\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Setup NGINX Virtual Hosts on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI","description":"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here's how to setup NGINX virtual hosts on CentOS.","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:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI","og_description":"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here's how to setup NGINX virtual hosts on CentOS.","og_url":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-08-28T06:47:24+00:00","article_modified_time":"2025-12-23T05:50:03+00:00","og_image":[{"width":1200,"height":939,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Setup NGINX Virtual Hosts on CentOS","datePublished":"2020-08-28T06:47:24+00:00","dateModified":"2025-12-23T05:50:03+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/"},"wordCount":644,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1","keywords":["virtual hosts"],"articleSection":["Nginx"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/","url":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/","name":"How to Setup NGINX Virtual Hosts on CentOS - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1","datePublished":"2020-08-28T06:47:24+00:00","dateModified":"2025-12-23T05:50:03+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"NGINX virtual hosts allow you to host multiple websites and domains in same web server. Here's how to setup NGINX virtual hosts on CentOS.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1","width":1200,"height":939,"caption":"nginx virtual hosts"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/setup-nginx-virtual-hosts-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Setup NGINX Virtual Hosts on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/08\/nginx-virtual-hosts.jpg?fit=1200%2C939&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-oh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/1505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=1505"}],"version-history":[{"count":15,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/1505\/revisions"}],"predecessor-version":[{"id":10159,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/1505\/revisions\/10159"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/1511"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=1505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=1505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=1505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}