{"id":11767,"date":"2026-02-23T10:10:32","date_gmt":"2026-02-23T04:40:32","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=11767"},"modified":"2026-02-23T10:10:44","modified_gmt":"2026-02-23T04:40:44","slug":"install-apache-web-server-in-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux","title":{"rendered":"How to Install Apache Web Server in Linux 2026"},"content":{"rendered":"\n<p><strong>Apache Web Server<\/strong> is one of the most popular open source web server solutions, widely used worldwide for hosting websites.<\/p>\n\n\n\n<p>Known for its robustness, flexibility, and compatibility with various operating systems, including&nbsp;Linux, Apache is a reliable choice for web server setups.<\/p>\n\n\n\n<p>This guide will walk you through installing the Apache web server on popular Linux distributions like Ubuntu, Debian, CentOS, Fedora, and Arch Linux, whether you\u2019re a beginner or an experienced system administrator.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h2>\n\n\n\n<p>Before you begin the installation, there are a few things to keep in mind:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You should have a fresh or updated installation of a Linux distribution.<\/li>\n\n\n\n<li>Ensure you have sudo or root privileges on the system.<\/li>\n\n\n\n<li>Your system\u2019s package manager should be updated to install the latest packages.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-apache-web-server-on-various-linux-distributions\"><strong>Install Apache Web Server on Various Linux Distributions<\/strong><\/h2>\n\n\n\n<p>Apache is one of the most popular web servers that powers websites across the globe. Depending on your Linux distribution, the installation process can differ. <\/p>\n\n\n\n<p>In this guide, we\u2019ll walk you through installing Apache Web Server on Ubuntu\/Debian, CentOS\/RHEL\/Fedora, and Arch Linux, ensuring smooth deployment regardless of your system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-apache-web-server-on-ubuntu-debian\"><strong>Install Apache Web Server on Ubuntu\/Debian<\/strong><\/h3>\n\n\n\n<p>For Ubuntu and Debian based systems, installing Apache is simple.<\/p>\n\n\n\n<p><strong>Follow the command below:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Update the package list<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Install Apache2 package<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Verify Apache Installation<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Check that Apache is installed and running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status apache2<\/code><\/pre>\n\n\n\n<p>To check the Apache version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apache2 -v<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Allow Apache Through the Firewall (UFW)<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If you are using UFW (Uncomplicated Firewall) on Ubuntu or Debian, allow Apache traffic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow in \"Apache Full\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-apache-web-server-on-centos-rhel-fedora\"><strong>Install Apache Web Server on CentOS\/RHEL\/Fedora<\/strong><\/h3>\n\n\n\n<p>On CentOS, RHEL, and Fedora, Apache is known as&nbsp;<code>httpd<\/code>. Here\u2019s how to install it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Update the System and Install Apache<\/strong><\/li>\n<\/ul>\n\n\n\n<p>For CentOS\/RHEL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo <a href=\"https:\/\/www.youstable.com\/blog\/install-yum-on-linux\">yum install<\/a> httpd<\/code><\/pre>\n\n\n\n<p>For Fedora:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install httpd<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Start and Enable Apache Service<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Start the Apache service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start httpd<\/code><\/pre>\n\n\n\n<p><strong>Enable Apache to start on boot:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable httpd<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Check Apache Status<\/strong><\/li>\n<\/ul>\n\n\n\n<p>To ensure Apache is running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status httpd<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Configure the Firewall (firewall)<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If you are using firewalld, allow HTTP traffic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --permanent --add-service=http\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-apache-web-server-on-arch-linux\"><strong>Install Apache Web Server on Arch Linux<\/strong><\/h3>\n\n\n\n<p>Apache installation on Arch Linux follows a similar process.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Update the System<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Syu<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Install Apache<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -S apache<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Start and Enable Apache Service<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Start Apache:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start httpd<\/code><\/pre>\n\n\n\n<p>Enable Apache on boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable httpd<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Check Apache Status<\/strong><\/li>\n<\/ul>\n\n\n\n<p>To verify that Apache is running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status httpd<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Configure Firewall<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If you\u2019re using&nbsp;<code>ufw<\/code>&nbsp;or&nbsp;<code>firewalld<\/code>, allow HTTP traffic on Arch:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>For ufw<\/strong>:&nbsp;<code>sudo ufw allow in \"Apache Full\"<\/code><\/li>\n\n\n\n<li><strong>For firewalld<\/strong>:&nbsp;<code>sudo firewall-cmd --permanent --add-service=http<\/code><\/li>\n<\/ul>\n\n\n\n<p><em>Check Out |&nbsp;<a href=\"https:\/\/www.youstable.com\/blog\/knowledgebase\/installing-docker-on-ubuntu\/\">Installing Docker on Ubuntu<\/a><\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"create-a-new-apache-virtual-host\">Create a new Apache Virtual Host<\/h2>\n\n\n\n<p>Create a configuration file specifying your web application\u2019s domain and directory to set up a custom Apache virtual host. This process allows you to disable the default virtual host and configure Apache to listen for incoming requests on your desired domain. Follow the steps below to configure Apache for your custom virtual host setup.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a New Virtual Host Configuration File<\/strong><\/li>\n<\/ul>\n\n\n\n<p>First, create a new Apache virtual host configuration file in the&nbsp;<code>\/etc\/apache2\/sites-available\/<\/code>&nbsp;directory. For this example, we will name it&nbsp;<code>website.conf<\/code>. Open the file with a text editor, such as&nbsp;<code>nano<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/etc\/apache2\/sites-available\/website.conf<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Add Virtual Host Configuration<\/strong><\/li>\n<\/ul>\n\n\n\n<p>In the&nbsp;<code>website.conf<\/code>&nbsp;file, add the following configuration. Replace&nbsp;<code>app.example.com<\/code>&nbsp;with your domain name and&nbsp;<code>webmaster@example.com<\/code>&nbsp;with your web administrator email: apacheconfCopyEdit<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80&gt;\n    ServerAdmin webmaster@example.com\n    ServerName app.example.com\n\n    DocumentRoot \/var\/www\/html\/website\n    DirectoryIndex index.html index.php\n\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n    &lt;Directory \/var\/www\/html\/website&gt;\n        Options Indexes FollowSymLinks\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n\n\n\n<p>This configuration tells Apache to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Listen for requests on port 80 (default HTTP port).<\/li>\n\n\n\n<li>Use your specified domain (<code>app.example.com<\/code>).<\/li>\n\n\n\n<li>Serve the content from the&nbsp;<code>\/var\/www\/html\/website<\/code>&nbsp;directory.<\/li>\n\n\n\n<li>Use&nbsp;<code>index.html<\/code>&nbsp;or&nbsp;<code>index.php<\/code>&nbsp;as the default file to serve.<\/li>\n\n\n\n<li>Log errors and access requests to specified log files.<\/li>\n\n\n\n<li>Apply additional directory specific settings, such as allowing\u00a0<code>.htaccess<\/code>\u00a0overrides.<\/li>\n\n\n\n<li><strong>Save and Close the File<\/strong><\/li>\n<\/ul>\n\n\n\n<p>After adding the configuration, save and close the file by pressing&nbsp;<code>CTRL + X<\/code>, then&nbsp;<code>Y<\/code>, and finally&nbsp;<code>Enter<\/code>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Disable the Default Apache Virtual Host<\/strong><\/li>\n<\/ul>\n\n\n\n<p>To prevent Apache from using the default virtual host, disable it with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo a2dissite 000-default<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enable the New Virtual Host Configuration<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Enable the new virtual host configuration by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo a2ensite website<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Test Apache Configuration<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Run the following command to test if your Apache configuration contains any errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apachectl configtest<\/code><\/pre>\n\n\n\n<p>You should see the output&nbsp;<code>Syntax OK<\/code>&nbsp;if there are no errors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create the Web Root Directory<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If it doesn\u2019t exist yet, create the web root directory specified in the configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo <a href=\"https:\/\/www.youstable.com\/blog\/mkdir-command-in-linux\">mkdir<\/a> -p \/var\/www\/html\/website<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Add a Sample HTML File<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Next, create a simple&nbsp;<code>index.html<\/code>&nbsp;file in the&nbsp;<code>\/var\/www\/html\/website<\/code>&nbsp;directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/var\/www\/html\/website\/index.html<\/code><\/pre>\n\n\n\n<p>Add the following HTML content to display a \u201cGreetings from YouStable\u201d message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;Apache Web Server&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;Greetings from YouStable&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Save and close the file.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Set Permissions for the Web Root Directory<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Grant ownership privileges to the Apache web server user (<code>www-data<\/code>) for the web root directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo chown -R www-data:www-data \/var\/www\/html\/website<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Restart Apache to Apply Changes<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Finally, restart the Apache service to apply the configuration changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl restart apache2<\/code><\/pre>\n\n\n\n<p>Your Apache web server is configured to serve a website from your custom virtual host using the domain&nbsp;<code>app.example.com<\/code>&nbsp;on port 80. When you access this domain, it should display the \u201cGreetings from YouStable\u201d message.<\/p>\n\n\n\n<p><em>Check Out |\u00a0<a href=\"https:\/\/www.youstable.com\/blog\/install-pip-on-ubuntu\/\">How to Easily Install PIP on Ubuntu in 2026<\/a><\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p><strong>Installing Apache on Linux is<\/strong> straightforward, whether you\u2019re using Ubuntu, Debian, CentOS, Fedora, or Arch Linux. Once installed, you can start configuring Apache to host your websites and applications.<\/p>\n\n\n\n<p>From modifying virtual hosts to <a href=\"https:\/\/www.youstable.com\/blog\/how-to-enable-ssl-in-cpanel\">enabling SSL<\/a>, Apache provides a wide range of features catering to beginners and advanced users. Following this guide, you\u2019ve successfully set up Apache on your Linux system. <\/p>\n\n\n\n<p>For further customization, check out Apache\u2019s official documentation and explore advanced features like setting up SSL, configuring mod_rewrite, and enabling PHP.<a href=\"https:\/\/web.archive.org\/web\/20250718071527\/https:\/\/twitter.com\/intent\/tweet?url=https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/web.archive.org\/web\/20250718071527\/https:\/\/www.facebook.com\/sharer\/sharer.php?u=https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/web.archive.org\/web\/20250718071527\/https:\/\/pinterest.com\/pin\/create\/button\/?url=https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux\/&amp;media=&amp;description=\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/web.archive.org\/web\/20250718071527\/https:\/\/plus.google.com\/share?url=https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/web.archive.org\/web\/20250718071527\/mailto:\/?Subject=Awesome%20Post&amp;body=https:\/\/www.youstable.com\/blog\/install-apache-web-server-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Web Server is one of the most popular open source web server solutions, widely used worldwide for hosting websites. [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":15119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"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":""}},"iawp_total_views":3,"footnotes":""},"categories":[350],"tags":[2100],"class_list":["post-11767","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","tag-how-to-install-apache-web-server-in-linux"],"acf":[],"featured_image_src":"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/11\/How-to-Install-Apache-Web-Server-in-Linux.jpg","author_info":{"display_name":"Prahlad Prajapati","author_link":"https:\/\/www.youstable.com\/blog\/author\/prahladblog"},"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=11767"}],"version-history":[{"count":4,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11767\/revisions"}],"predecessor-version":[{"id":18961,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11767\/revisions\/18961"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/15119"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=11767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=11767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=11767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}