{"id":166,"date":"2026-05-28T23:22:12","date_gmt":"2026-05-29T06:22:12","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/"},"modified":"2026-05-28T23:22:12","modified_gmt":"2026-05-29T06:22:12","slug":"how-to-set-up-apache-virtual-hosts","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/","title":{"rendered":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>Apache virtual hosts let you run multiple websites on a single server using one IP address. Instead of spinning up a separate machine for every domain, Apache reads the incoming HTTP request&#8217;s <code class=\"\" data-line=\"\">Host<\/code> header and routes traffic to the correct document root. That&#8217;s the whole mechanism.<\/p>\n<p>You&#8217;ll need this if you&#8217;re self-managing a <a href=\"https:\/\/www.hostandtech.com\/vps-ssd-servers\">VPS SSD Hosting<\/a> plan and want to host more than one site without paying for separate servers. It&#8217;s also the standard setup on any bare Linux box where you&#8217;re not using a control panel like cPanel or Plesk to abstract this away for you.<\/p>\n<p>This guide covers name-based virtual hosting on Apache 2.4 running on Ubuntu 22.04 or 24.04. The config structure is nearly identical on AlmaLinux 8\/9 and Debian 12 \u2014 I&#8217;ll call out the differences where they matter.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>Root or sudo access to your server<\/li>\n<li>Apache 2.4 installed and running (<code class=\"\" data-line=\"\">apache2<\/code> on Ubuntu\/Debian, <code class=\"\" data-line=\"\">httpd<\/code> on AlmaLinux\/CentOS)<\/li>\n<li>A domain name with DNS A records pointing to your server&#8217;s public IP<\/li>\n<li>DNS propagation complete \u2014 allow up to 24 hours, though most records resolve within 1-2 hours<\/li>\n<li>Basic comfort with the Linux command line and a terminal text editor (nano is fine)<\/li>\n<\/ul>\n<h2>Step-by-Step Instructions<\/h2>\n<h3>Step 1: Create the Document Root Directories<\/h3>\n<p>Each site needs its own directory where its files will live. The conventional location on Ubuntu is <code class=\"\" data-line=\"\">\/var\/www\/<\/code>. Create one folder per domain:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-1\"><code class=\"\" data-line=\"\">sudo mkdir -p \/var\/www\/example.com\/public_html\nsudo mkdir -p \/var\/www\/secondsite.com\/public_html<\/code><\/pre>\n<\/div>\n<p>Now set ownership so Apache (and your user account) can read and write to those directories:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-2\"><code class=\"\" data-line=\"\">sudo chown -R $USER:$USER \/var\/www\/example.com\/public_html\nsudo chown -R $USER:$USER \/var\/www\/secondsite.com\/public_html\nsudo chmod -R 755 \/var\/www<\/code><\/pre>\n<\/div>\n<p>Drop a quick test page in each so you can confirm routing works later:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-3\"><code class=\"\" data-line=\"\">echo &#039;&lt;h1&gt;example.com is working&lt;\/h1&gt;&#039; &gt; \/var\/www\/example.com\/public_html\/index.html\necho &#039;&lt;h1&gt;secondsite.com is working&lt;\/h1&gt;&#039; &gt; \/var\/www\/secondsite.com\/public_html\/index.html<\/code><\/pre>\n<\/div>\n<h3>Step 2: Create the Virtual Host Config Files<\/h3>\n<p>On Ubuntu and Debian, virtual host configs live in <code class=\"\" data-line=\"\">\/etc\/apache2\/sites-available\/<\/code>. Each site gets its own <code class=\"\" data-line=\"\">.conf<\/code> file. This separation makes it easy to enable or disable sites without editing a monolithic config.<\/p>\n<p>Create the config for your first domain:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-4\"><code class=\"\" data-line=\"\">sudo nano \/etc\/apache2\/sites-available\/example.com.conf<\/code><\/pre>\n<\/div>\n<p>Paste in the following, substituting your actual domain and paths:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-5\"><code class=\"\" data-line=\"\">&lt;VirtualHost *:80&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\/public_html\n\n    ErrorLog ${APACHE_LOG_DIR}\/example.com-error.log\n    CustomLog ${APACHE_LOG_DIR}\/example.com-access.log combined\n\n    &lt;Directory \/var\/www\/example.com\/public_html&gt;\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<\/div>\n<p>Repeat the same process for your second domain:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-6\"><code class=\"\" data-line=\"\">sudo nano \/etc\/apache2\/sites-available\/secondsite.com.conf<\/code><\/pre>\n<\/div>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-7\"><code class=\"\" data-line=\"\">&lt;VirtualHost *:80&gt;\n    ServerName secondsite.com\n    ServerAlias www.secondsite.com\n    DocumentRoot \/var\/www\/secondsite.com\/public_html\n\n    ErrorLog ${APACHE_LOG_DIR}\/secondsite.com-error.log\n    CustomLog ${APACHE_LOG_DIR}\/secondsite.com-access.log combined\n\n    &lt;Directory \/var\/www\/secondsite.com\/public_html&gt;\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd <strong>Note:<\/strong> On AlmaLinux or CentOS with <code class=\"\" data-line=\"\">httpd<\/code>, there&#8217;s no <code class=\"\" data-line=\"\">sites-available<\/code> \/ <code class=\"\" data-line=\"\">sites-enabled<\/code> split. You&#8217;d place these configs directly in <code class=\"\" data-line=\"\">\/etc\/httpd\/conf.d\/<\/code> and they&#8217;re automatically loaded. Skip Steps 3 and 4 and go straight to the syntax check.<\/p>\n<h3>Step 3: Enable the Virtual Host Configs<\/h3>\n<p>Ubuntu&#8217;s Apache uses symlinks to activate configs. The <code class=\"\" data-line=\"\">a2ensite<\/code> command creates those symlinks from <code class=\"\" data-line=\"\">sites-available<\/code> into <code class=\"\" data-line=\"\">sites-enabled<\/code> for you:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-8\"><code class=\"\" data-line=\"\">sudo a2ensite example.com.conf\nsudo a2ensite secondsite.com.conf<\/code><\/pre>\n<\/div>\n<p>If the default Apache placeholder page is still enabled, disable it so it doesn&#8217;t intercept requests:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-9\"><code class=\"\" data-line=\"\">sudo a2dissite 000-default.conf<\/code><\/pre>\n<\/div>\n<p>\u26a0 <strong>Warning:<\/strong> Leaving <code class=\"\" data-line=\"\">000-default.conf<\/code> enabled is a very common mistake. Apache processes virtual hosts in alphabetical order, and <code class=\"\" data-line=\"\">000-default<\/code> sorts first. If it&#8217;s still active, it&#8217;ll catch requests that don&#8217;t match any other vhost \u2014 including yours during DNS propagation \u2014 and serve the Apache default page instead of your site.<\/p>\n<h3>Step 4: Test the Config and Reload Apache<\/h3>\n<p>Before reloading, always run a syntax check. This catches typos that would bring down all sites on the server, not just the one you edited:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-10\"><code class=\"\" data-line=\"\">sudo apache2ctl configtest<\/code><\/pre>\n<\/div>\n<p>You&#8217;re looking for <code class=\"\" data-line=\"\">Syntax OK<\/code> at the end of the output. If you see errors, fix them before proceeding.<\/p>\n<p>Once the check passes, reload Apache to apply the new configs without dropping active connections:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-11\"><code class=\"\" data-line=\"\">sudo systemctl reload apache2<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd <strong>Note:<\/strong> Use <code class=\"\" data-line=\"\">reload<\/code> here, not <code class=\"\" data-line=\"\">restart<\/code>. A reload sends a graceful signal that lets existing connections finish. A restart terminates everything immediately \u2014 that matters on a live server.<\/p>\n<h3>Step 5: Verify the Sites Are Working<\/h3>\n<p>Open a browser and visit <code class=\"\" data-line=\"\">http:\/\/example.com<\/code> and <code class=\"\" data-line=\"\">http:\/\/secondsite.com<\/code>. You should see the test pages you created in Step 1.<\/p>\n<p>If DNS hasn&#8217;t propagated yet and you want to test locally, you can fake it by adding entries to your local <code class=\"\" data-line=\"\">\/etc\/hosts<\/code> file (on Mac or Linux) or <code class=\"\" data-line=\"\">C:WindowsSystem32driversetchosts<\/code> on Windows:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-12\"><code class=\"\" data-line=\"\">YOUR_SERVER_IP  example.com www.example.com\nYOUR_SERVER_IP  secondsite.com www.secondsite.com<\/code><\/pre>\n<\/div>\n<p>Remove those lines once DNS is properly set up. Forgetting to clean up <code class=\"\" data-line=\"\">\/etc\/hosts<\/code> will make you think DNS is working when it&#8217;s actually still routing locally \u2014 I&#8217;ve wasted an embarrassing amount of time on that one.<\/p>\n<h3>Step 6: Add SSL (Recommended)<\/h3>\n<p>Serving sites over plain HTTP in 2026 will get you a browser warning and a rankings penalty. The fastest path to SSL on a self-managed server is Certbot with the Let&#8217;s Encrypt CA:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-13\"><code class=\"\" data-line=\"\">sudo apt install certbot python3-certbot-apache -y\nsudo certbot --apache -d example.com -d www.example.com<\/code><\/pre>\n<\/div>\n<p>Certbot will modify your virtual host config to add port 443 blocks and handle the HTTP-to-HTTPS redirect automatically. Run the same command again for <code class=\"\" data-line=\"\">secondsite.com<\/code>.<\/p>\n<h2>Common Issues &amp; Troubleshooting<\/h2>\n<h3>Apache Serves the Wrong Site or the Default Page<\/h3>\n<p>Almost always caused by <code class=\"\" data-line=\"\">000-default.conf<\/code> still being enabled, or a missing\/wrong <code class=\"\" data-line=\"\">ServerName<\/code> directive. Double-check that <code class=\"\" data-line=\"\">ServerName<\/code> exactly matches the domain you&#8217;re requesting (no trailing slash, no typos). Run <code class=\"\" data-line=\"\">sudo apache2ctl -S<\/code> to see which virtual host Apache thinks owns each domain \u2014 it prints the full vhost mapping to stdout, which is much faster than guessing.<\/p>\n<h3>403 Forbidden on the Document Root<\/h3>\n<p>This usually means a permissions problem on the directory. Apache&#8217;s worker process runs as <code class=\"\" data-line=\"\">www-data<\/code> on Ubuntu. It needs at least execute (<code class=\"\" data-line=\"\">x<\/code>) permission on every directory in the path and read (<code class=\"\" data-line=\"\">r<\/code>) on the files. The <code class=\"\" data-line=\"\">chmod 755<\/code> from Step 1 handles the web root itself, but if your document root is nested somewhere unusual (like inside a user&#8217;s home directory), every parent directory needs <code class=\"\" data-line=\"\">x<\/code> for <code class=\"\" data-line=\"\">www-data<\/code> too. Also confirm your <code class=\"\" data-line=\"\">&lt;Directory&gt;<\/code> block has <code class=\"\" data-line=\"\">Require all granted<\/code>.<\/p>\n<h3>Changes to the Config File Aren&#8217;t Taking Effect<\/h3>\n<p>You edited the file in <code class=\"\" data-line=\"\">sites-available<\/code> but forgot that the active file is a symlink in <code class=\"\" data-line=\"\">sites-enabled<\/code>. The symlink points to the original, so edits do propagate \u2014 but you still need to reload Apache. If you ran <code class=\"\" data-line=\"\">systemctl reload apache2<\/code> and it didn&#8217;t help, check that the configtest passes and look at the error log: <code class=\"\" data-line=\"\">sudo tail -f \/var\/log\/apache2\/example.com-error.log<\/code>.<\/p>\n<h3>ServerName Mismatch Warning in Error Logs<\/h3>\n<p>You&#8217;ll see something like: <code class=\"\" data-line=\"\">AH00558: apache2: Could not reliably determine the server&#039;s fully qualified domain name<\/code>. This is harmless but annoying. Fix it by setting a global <code class=\"\" data-line=\"\">ServerName<\/code> in <code class=\"\" data-line=\"\">\/etc\/apache2\/apache2.conf<\/code>:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-14\"><code class=\"\" data-line=\"\">ServerName localhost<\/code><\/pre>\n<\/div>\n<p>Then reload. The warning disappears. It doesn&#8217;t affect how your virtual hosts work.<\/p>\n<h3>Certbot Fails with &#8220;Could Not Automatically Find a Matching Server Block&#8221;<\/h3>\n<p>Certbot&#8217;s Apache plugin finds your vhost by matching the <code class=\"\" data-line=\"\">-d<\/code> domain against <code class=\"\" data-line=\"\">ServerName<\/code> directives. If your <code class=\"\" data-line=\"\">ServerName<\/code> is missing or uses a different capitalisation, it won&#8217;t find the block. Confirm the exact string in your <code class=\"\" data-line=\"\">.conf<\/code> file matches what you&#8217;re passing to <code class=\"\" data-line=\"\">certbot -d<\/code>. Also make sure port 80 is open in your firewall \u2014 Certbot needs to complete an HTTP-01 challenge before it&#8217;ll issue the certificate.<\/p>\n<h2>FAQ<\/h2>\n<div class=\"ht-faq-section\">\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How many virtual hosts can Apache handle on one server?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>There&#8217;s no hard limit built into Apache itself. In practice, it&#8217;s constrained by your server&#8217;s RAM, CPU, and available file descriptors. A modest VPS with 2GB RAM can comfortably handle dozens of low-traffic sites. High-traffic sites need more resources per vhost, so plan accordingly.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Do I need a separate IP address for each virtual host?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>No. Name-based virtual hosting \u2014 which is what this guide sets up \u2014 lets multiple domains share one IP address. Apache reads the HTTP Host header to figure out which site to serve. You&#8217;d only need separate IPs for IP-based virtual hosting, which is essentially obsolete now that SNI handles SSL on shared IPs.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">What&#039;s the difference between sites-available and sites-enabled in Apache?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>sites-available holds all your config files, active or not. sites-enabled holds symlinks to whichever configs you&#8217;ve actually activated with a2ensite. It&#8217;s a clean way to stage configs and disable a site without deleting its config file. On RedHat-based systems like AlmaLinux, this split doesn&#8217;t exist \u2014 all .conf files in \/etc\/httpd\/conf.d\/ are loaded automatically.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Can I use Apache virtual hosts with WordPress?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Yes, and it&#8217;s a common setup. You&#8217;ll want AllowOverride All in your Directory block so WordPress&#8217;s .htaccess file can handle pretty permalinks. Without it, all URLs except the homepage return a 404. If you&#8217;d rather not manage this yourself, Host &amp; Tech&#8217;s managed WordPress hosting handles the server config for you.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I test a virtual host before DNS is pointed at my server?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Edit your local machine&#8217;s \/etc\/hosts file (or C:WindowsSystem32driversetchosts on Windows) and add a line mapping your server&#8217;s IP to the domain. This overrides DNS resolution on your machine only. Just remember to remove those lines once real DNS is working, or you&#8217;ll keep bypassing the actual DNS records without realising it.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Running multiple websites on one server means setting up Apache virtual hosts. It&#8217;s not complicated once you understand the structure, but there are a few gotchas that&#8217;ll burn you if you skip the details.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[49],"tags":[51,310,12,312,311,15,309,86],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-linux","tag-apache","tag-centos","tag-linux","tag-multiple-sites","tag-site-configuration","tag-ubuntu","tag-virtual-hosts","tag-web-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server<\/title>\n<meta name=\"description\" content=\"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/\" \/>\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 Apache Virtual Hosts to Run Multiple Sites on One Server\" \/>\n<meta property=\"og:description\" content=\"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-29T06:22:12+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server\",\"datePublished\":\"2026-05-29T06:22:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/\"},\"wordCount\":1373,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"Apache\",\"centos\",\"Linux\",\"multiple sites\",\"site configuration\",\"Ubuntu\",\"virtual hosts\",\"web server\"],\"articleSection\":[\"Linux Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/\",\"name\":\"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-05-29T06:22:12+00:00\",\"description\":\"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/how-to-set-up-apache-virtual-hosts\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server","description":"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.","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:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server","og_description":"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.","og_url":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-05-29T06:22:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server","datePublished":"2026-05-29T06:22:12+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/"},"wordCount":1373,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["Apache","centos","Linux","multiple sites","site configuration","Ubuntu","virtual hosts","web server"],"articleSection":["Linux Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/","url":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/","name":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-05-29T06:22:12+00:00","description":"Learn how to configure Apache virtual hosts to host multiple websites on a single Linux server. Step-by-step setup with real config examples.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/linux\/how-to-set-up-apache-virtual-hosts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Set Up Apache Virtual Hosts to Run Multiple Sites on One Server"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}