{"id":2414,"date":"2025-12-19T16:16:40","date_gmt":"2025-12-19T22:16:40","guid":{"rendered":"https:\/\/izendestudioweb.com\/articles\/?p=2414"},"modified":"2025-12-19T16:16:40","modified_gmt":"2025-12-19T22:16:40","slug":"mastering-apache-web-server-installation-on-ubuntu-a-comprehensive-guide","status":"publish","type":"post","link":"https:\/\/izendestudioweb.com\/articles\/2025\/12\/19\/mastering-apache-web-server-installation-on-ubuntu-a-comprehensive-guide\/","title":{"rendered":"Mastering Apache Web Server Installation on Ubuntu: A Comprehensive Guide"},"content":{"rendered":"<p>The Apache HTTP Server has stood the test of time as one of the most <strong>reliable web servers<\/strong> available. Since its inception in 1995, Apache has been favored for its <strong>open-source nature<\/strong> and extensive customization options. In a world increasingly reliant on web applications, setting up an Apache server on <strong>Ubuntu<\/strong> remains a relevant skill, especially with the latest Ubuntu 24.04 LTS release.<\/p>\n<p>This guide will walk you through the steps to install Apache on Ubuntu, configure firewall settings, set up virtual hosts, and secure your server with HTTPS using Let\u2019s Encrypt. Whether you\u2019re hosting a personal blog or managing a cloud-based application, this tutorial aims to equip you with the tools and knowledge necessary for a successful deployment.<\/p>\n<h2>Prerequisites for Setting Up Apache<\/h2>\n<p>Before diving into the installation process, ensure that you have the following:<\/p>\n<ul>\n<li>A non-root user with <strong>sudo privileges<\/strong>.<\/li>\n<li>An active firewall to block unnecessary ports.<\/li>\n<li>Access to the terminal on your Ubuntu server.<\/li>\n<\/ul>\n<p>If you haven&#8217;t set up a non-root user yet, refer to our <strong>initial server setup guide<\/strong> for Ubuntu.<\/p>\n<h2>Installing Apache on Ubuntu<\/h2>\n<p>Apache is available in Ubuntu&#8217;s default package repository, making installation straightforward. Follow these steps to install Apache:<\/p>\n<ol>\n<li>Update your package index:<\/li>\n<\/ol>\n<p><strong>sudo apt update<\/strong><\/p>\n<ol start=\"2\">\n<li>Install the Apache package:<\/li>\n<\/ol>\n<p><strong>sudo apt install apache2<\/strong><\/p>\n<p>After installation, verify that Apache is running:<\/p>\n<p><strong>sudo systemctl status apache2<\/strong><\/p>\n<p>If everything is functioning correctly, you should see a status of <strong>active (running)<\/strong>.<\/p>\n<h3>Configuring the Firewall<\/h3>\n<p>Next, you will need to configure your firewall to allow web traffic. If you are using <strong>UFW (Uncomplicated Firewall)<\/strong>, follow these steps:<\/p>\n<ol>\n<li>Check available application profiles:<\/li>\n<\/ol>\n<p><strong>sudo ufw app list<\/strong><\/p>\n<ol start=\"2\">\n<li>Allow both HTTP and HTTPS traffic by enabling the <strong>Apache Full<\/strong> profile:<\/li>\n<\/ol>\n<p><strong>sudo ufw allow &#8216;Apache Full&#8217;<\/strong><\/p>\n<p>To verify that the rule is applied, run:<\/p>\n<p><strong>sudo ufw status<\/strong><\/p>\n<p>This will confirm that Apache is now allowed through the firewall.<\/p>\n<h2>Setting Up Virtual Hosts for Multiple Domains<\/h2>\n<p>If you plan to host multiple websites on your server, <strong>virtual hosts<\/strong> are essential. This allows each domain to have its own configuration. Here\u2019s how to set it up:<\/p>\n<ol>\n<li>Create a directory for your domain:<\/li>\n<\/ol>\n<p><strong>sudo mkdir \/var\/www\/example.com<\/strong><\/p>\n<ol start=\"2\">\n<li>Assign ownership to your current user:<\/li>\n<\/ol>\n<p><strong>sudo chown -R $USER:$USER \/var\/www\/example.com<\/strong><\/p>\n<ol start=\"3\">\n<li>Create a simple index.html file:<\/li>\n<\/ol>\n<p><strong>sudo nano \/var\/www\/example.com\/index.html<\/strong><\/p>\n<p>Insert the following HTML content:<\/p>\n<p><em>&lt;html&gt;&lt;head&gt;&lt;title&gt;Welcome to example.com!&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;Success! The example.com virtual host is working!&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;<\/em><\/p>\n<ol start=\"4\">\n<li>Create and configure your virtual host file:<\/li>\n<\/ol>\n<p><strong>sudo nano \/etc\/apache2\/sites-available\/example.com.conf<\/strong><\/p>\n<p>Populate it with:<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>Enable the site:<\/p>\n<p><strong>sudo a2ensite example.com.conf<\/strong><\/p>\n<p>And disable the default site:<\/p>\n<p><strong>sudo a2dissite 000-default.conf<\/strong><\/p>\n<p>Finally, test your configuration:<\/p>\n<p><strong>sudo apache2ctl configtest<\/strong><\/p>\n<p>If successful, reload Apache:<\/p>\n<p><strong>sudo systemctl reload apache2<\/strong><\/p>\n<\/p>\n<h2>Securing Your Server with HTTPS<\/h2>\n<p>In today\u2019s digital landscape, securing your site with HTTPS is non-negotiable. You can achieve this using <strong>Let\u2019s Encrypt<\/strong>, a free certificate authority. Here\u2019s how to set it up:<\/p>\n<ol>\n<li>Install Certbot and the Apache plugin:<\/li>\n<\/ol>\n<p><strong>sudo apt install certbot python3-certbot-apache<\/strong><\/p>\n<ol start=\"2\">\n<li>Request a Let&#8217;s Encrypt certificate:<\/li>\n<\/ol>\n<p><strong>sudo certbot &#8211;apache -d example.com -d www.example.com<\/strong><\/p>\n<p>During this process, Certbot will automatically configure HTTPS and set up a renewal process.<\/p>\n<h3>Verifying Your SSL Certificate<\/h3>\n<p>To check your SSL certificate&#8217;s status, run:<\/p>\n<p><strong>sudo certbot certificates<\/strong><\/p>\n<p>A successful response will confirm that your certificate is valid.<\/p>\n<h2>Conclusion<\/h2>\n<p>By following this guide, you have successfully installed the Apache web server on your Ubuntu machine, configured it to serve multiple domains, and secured it with HTTPS. This knowledge empowers you to manage your web hosting needs efficiently, whether on a local server or in the cloud. With the right setup, your Apache server will be ready to deliver excellent performance for your applications, ensuring a secure experience for your users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to install and configure Apache on Ubuntu, ensuring a secure and efficient web server for your applications.<\/p>\n","protected":false},"author":2,"featured_media":2413,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[105,104,103],"class_list":["post-2414","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-hosting","tag-cloud","tag-hosting","tag-local"],"jetpack_featured_media_url":"https:\/\/izendestudioweb.com\/articles\/wp-content\/uploads\/2025\/12\/img-SEPdYgpXfNFt0N5HJPSIPAiq.png","_links":{"self":[{"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/posts\/2414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/comments?post=2414"}],"version-history":[{"count":1,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/posts\/2414\/revisions"}],"predecessor-version":[{"id":2469,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/posts\/2414\/revisions\/2469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/media\/2413"}],"wp:attachment":[{"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/media?parent=2414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/categories?post=2414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/izendestudioweb.com\/articles\/wp-json\/wp\/v2\/tags?post=2414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}