{"id":503,"date":"2024-05-03T16:03:12","date_gmt":"2024-05-03T16:03:12","guid":{"rendered":"https:\/\/zahiralam.com\/blog\/?p=503"},"modified":"2024-05-03T16:03:12","modified_gmt":"2024-05-03T16:03:12","slug":"how-to-install-apache-web-server-on-ubuntu-24-04-lts-a-detailed-guide","status":"publish","type":"post","link":"https:\/\/zahiralam.com\/blog\/how-to-install-apache-web-server-on-ubuntu-24-04-lts-a-detailed-guide\/","title":{"rendered":"How to Install Apache Web Server on Ubuntu 24.04 LTS: A Detailed Guide"},"content":{"rendered":"\n<p>Apache HTTP Server is one of the most widely used web servers in the world. It&#8217;s robust, reliable, and highly customizable, making it a preferred choice for hosting websites. If you&#8217;re running Ubuntu 24.04 LTS, installing Apache is straightforward and can be done with just a few commands. This guide will take you through the process step-by-step.\n\n\n\n<p>Apache serves as the backbone for countless web applications on the internet. It can host everything from personal blogs to large enterprise websites. Ubuntu&#8217;s APT package manager makes it simple to install and manage Apache packages, ensuring you get the latest stable version and security updates.\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before proceeding, you should have:\n\n\n\n<ul class=\"wp-block-list\">\n<li>A machine running Ubuntu 24.04 LTS.<\/li>\n\n\n\n<li>A user account with <code>sudo<\/code> privileges.<\/li>\n\n\n\n<li>Access to a terminal\/command line.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step-by-Step Installation<\/h2>\n\n\n\n<p><strong>Step 1: Update Your Package Index<\/strong>\n\n\n\n<p>Before installing any software, it&#8217;s good practice to update your package manager&#8217;s index to ensure you&#8217;re accessing the latest versions available in the repository:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-1\">sudo apt update<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20update\">\n                            <button class=\"copy-button\" data-label=\"sudo apt update\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p><strong>Step 2: Install Apache<\/strong>\n\n\n\n<p>Install Apache2 using the following command. This command will retrieve the latest Apache package from Ubuntu&#8217;s repositories:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-2\">sudo apt install apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20install%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo apt install apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p><strong>Step 3: Adjust the Firewall<\/strong>\n\n\n\n<p>If your server is protected by a firewall, specifically the Uncomplicated Firewall (UFW), you&#8217;ll need to allow traffic on HTTP (port 80) and HTTPS (port 443) to enable access to the web server:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-3\">sudo ufw allow &#039;Apache&#039;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20ufw%20allow%20%27Apache%27\">\n                            <button class=\"copy-button\" data-label=\"sudo ufw allow &#039;Apache&#039;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>To ensure the rules are applied and check the status, use:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-4\">sudo ufw status<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20ufw%20status\">\n                            <button class=\"copy-button\" data-label=\"sudo ufw status\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>The output should list &#8216;Apache&#8217; as an allowed service.\n\n\n\n<p><strong>Step 4: Verify Apache Installation<\/strong>\n\n\n\n<p>To confirm that Apache has been installed correctly and is running, you can check its status using the <code>systemctl<\/code> command:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-5\">sudo systemctl status apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20status%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl status apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>You should see an output indicating that the service is active. Alternatively, open a web browser and type your server\u2019s IP address. If Apache has been installed correctly, you will see the default Ubuntu Apache web page, which confirms that the server is up and running.\n\n\n\n<p><strong>Step 5: Managing Apache Service<\/strong>\n\n\n\n<p>Apache can be managed with <code>systemctl<\/code>. Here are some basic commands to manage your Apache service:\n\n\n\n<p>To stop Apache:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-6\">sudo systemctl stop apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20stop%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl stop apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>To start Apache when it has been stopped:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-7\">sudo systemctl start apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20start%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl start apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>To restart Apache (useful for reloading configurations):\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-8\">sudo systemctl restart apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20restart%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl restart apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>To reload Apache without dropping connections (ideal for applying minor configuration changes):\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-9\">sudo systemctl reload apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20reload%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl reload apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p><strong>Step 6: Enable Apache to Start at Boot<\/strong>\n\n\n\n<p>To make sure Apache starts automatically at boot, use:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-10\">sudo systemctl enable apache2<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20systemctl%20enable%20apache2\">\n                            <button class=\"copy-button\" data-label=\"sudo systemctl enable apache2\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>With Apache installed and configured on your Ubuntu 24.04 LTS system, you&#8217;re now ready to host websites and web applications. Apache&#8217;s extensive documentation and active community support make it an excellent choice for both beginners and experienced web administrators. Whether you&#8217;re hosting a small blog or a large-scale commercial site, Apache offers the flexibility and performance you need.\n","protected":false},"excerpt":{"rendered":"<p>Apache HTTP Server is one of the most widely used web servers in the world. It&#8217;s robust, reliable, and highly customizable, making it a preferred [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[13,68,66],"class_list":["post-503","post","type-post","status-publish","format-standard","hentry","category-ubuntu","tag-apache","tag-apache2","tag-ubuntu-24-04"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/comments?post=503"}],"version-history":[{"count":1,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":504,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions\/504"}],"wp:attachment":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}