{"id":109,"date":"2025-12-23T11:21:42","date_gmt":"2025-12-23T11:21:42","guid":{"rendered":"https:\/\/blog.jayapress.in\/?p=109"},"modified":"2025-12-23T11:29:53","modified_gmt":"2025-12-23T11:29:53","slug":"how-to-set-up-a-virtual-host-on-amazon-linux-2023-al2023","status":"publish","type":"post","link":"https:\/\/blog.jayapress.in\/index.php\/2025\/12\/23\/how-to-set-up-a-virtual-host-on-amazon-linux-2023-al2023\/","title":{"rendered":"How to set up a virtual host on Amazon Linux 2023 (AL2023)"},"content":{"rendered":"\n<p>To set up a virtual host on Amazon Linux 2023 (AL2023), you primarily use the Apache HTTP Server and configure it with virtual host directives in configuration files located in the directory.<br><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"585\" src=\"https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image-1024x585.png\" alt=\"\" class=\"wp-image-113\" style=\"width:725px;height:auto\" srcset=\"https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image-1024x585.png 1024w, https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image-300x171.png 300w, https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image-768x439.png 768w, https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image-1536x878.png 1536w, https:\/\/blog.jayapress.in\/wp-content\/uploads\/2025\/12\/image.png 1792w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Prerequisites<\/strong> &#8211;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An EC2 instance running Amazon Linux 2023.<\/li>\n\n\n\n<li>An installed Apache web server. If not installed:<\/li>\n\n\n\n<li>Configured security group rules (inbound) to allow HTTP (port 80) and HTTPS (port 443) traffic.<\/li>\n\n\n\n<li>A registered domain name pointing to your EC2 instance&#8217;s public IP address.<\/li>\n<\/ul>\n\n\n\n<p><strong>Steps to Configure an Apache Virtual Host<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to the Apache configuration directory: The recommended practice on Amazon Linux is to create configuration files in , as Apache automatically includes files in this directory that end with a extension.<br><code>cd \/etc\/httpd\/conf.d<\/code><\/li>\n\n\n\n<li>Create a virtual host configuration file: Use a text editor like or to create a new configuration file for your domain (e.g., ).<br><code>sudo nano yourdomain.com.conf<\/code><\/li>\n\n\n\n<li>Add the VirtualHost directives: Add the following configuration block to the file, replacing and with your actual domain name and desired document root path.<br><code>&lt;VirtualHost *:80&gt;<br>    ServerName yourdomain.com<br>    DocumentRoot \/var\/www\/html\/yourdomain.com<br><br>    &lt;Directory \/var\/www\/html\/yourdomain.com&gt;<br>        AllowOverride All<br>        Require all granted<br>    &lt;\/Directory&gt;<br><br>    ErrorLog \/var\/log\/httpd\/yourdomain.com-error.log<br>    CustomLog \/var\/log\/httpd\/yourdomain.com-access.log combined<br>&lt;\/VirtualHost&gt;<\/code><br><\/li>\n\n\n\n<li>Create the document root directory: Create the directory specified in the directive:<br><code>sudo mkdir -p \/var\/www\/html\/yourdomain.com<\/code><\/li>\n\n\n\n<li>Place content in the document root (optional test): Add a simple HTML file to test the configuration.<br><code>sudo echo \"Welcome to YourDomain.com\" &gt; \/var\/www\/html\/yourdomain.com<\/code><\/li>\n\n\n\n<li>Verify Apache configuration syntax: Check for any errors in your configuration files before restarting the service.<br><code>sudo httpd -t<\/code><\/li>\n\n\n\n<li>Restart Apache: Apply the changes by restarting the service.<br><code>sudo systemctl restart httpd<\/code><\/li>\n<\/ol>\n\n\n\n<p>After these steps, your Amazon Linux 2023 instance should be configured to serve the website associated with from the specified document root. You can configure SSL\/TLS for your virtual host using Certbot.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To set up a virtual host on Amazon Linux 2023 (AL2023), you primarily use the Apache HTTP Server and configure it with virtual host directives in configuration files located in the directory. Prerequisites &#8211; Steps to Configure an Apache Virtual Host After these steps, your Amazon Linux 2023 instance should be configured to serve the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[2],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":4,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jayapress.in\/index.php\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}