• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install Apache 2.4 on Ubuntu 22.04

How To Install Apache 2.4 on Ubuntu 22.04

sammbysamm
October 16, 2023
Install Apache 2.4 on Ubuntu

How To Install Apache 2.4 on Ubuntu Server 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

Apache HTTP Server, commonly referred to as Apache, is a powerful and widely used open-source web server software. Apache 2.4 is the latest version, boasting enhanced performance, security features, and scalability. If you’re running an Ubuntu 22.04, this comprehensive guide will take you through the step-by-step process of how to Install Apache 2.4 on Ubuntu 22.04. By following these instructions, you’ll have a robust foundation for hosting websites, applications, and more.

Table of Contents

  • Introduction
  • Why Choose Apache 2.4?
  • Installing Apache 2.4 on Ubuntu 22.04
    • Step 1: Update System Packages on Ubuntu 22.04
    • Step 2: Install Apache 2.4 on Ubuntu 22.04
    • Step 3: Check Apache version on Ubuntu 22.04
    • Step 4: Check Apache service on Ubuntu 22.04
    • Step 5: Configure Firewall on Ubuntu 22.04
    • Step 6: Test Apache Web Server
    • Step 7: Explore Apache Configuration
    • Step 8: Setting Up Virtual Hosts in Apache2
    • Step 9: Secure Your Website with HTTPS (Optional)
    • Step 10: Optimize Performance
  • Conclusion

Why Choose Apache 2.4?

Before we dive into the installation steps, let’s understand the benefits of Apache 2.4 and why it’s an excellent choice:

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

  1. Performance Improvements: Apache 2.4 introduces several performance enhancements, such as reduced memory usage and better handling of concurrent requests. This ensures smoother operations, even during high traffic periods.
  2. Enhanced Security: Security is a top priority. Apache 2.4 includes advanced security features like improved authentication and authorization modules, making it more resilient against cyber threats.
  3. Modular Architecture: Apache’s modular architecture allows you to add or remove modules as needed, optimizing the server for your specific use case.

Installing Apache 2.4 on Ubuntu 22.04

Follow these steps to install Apache 2.4 on your Ubuntu 22.04 and harness its powerful features for your web hosting needs:

Step 1: Update System Packages on Ubuntu 22.04

Begin by updating the package list to ensure you’re working with the latest software versions of your Ubuntu 22.04:

samm@apache:~$ sudo apt-get update
samm@apache:~$ sudo apt-get upgrade

This ensures your system is up-to-date before installing new software.

Step 2: Install Apache 2.4 on Ubuntu 22.04

With the package list updated, install Apache 2.4 using the following command:

samm@apache:~$ sudo apt install -y apache2

During installation, any required dependencies will also be installed automatically.

Step 3: Check Apache version on Ubuntu 22.04

Check for the currently active version of PHP on your Ubuntu 22.04 with the following command:

samm@apache:~$ apache2 -v
Server version: Apache/2.4.54 (Ubuntu)
Server built:   2023-06-08T15:59:07

Step 4: Check Apache service on Ubuntu 22.04

Once the installation is complete, Apache 2.4 on your Ubuntu 22.04 should be up and running. You can check its status using the following command:

samm@apache:~$ sudo systemctl status apache2
● apache2.service - Apache 2.4 HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-07-08 00:10:04 WIB; 1s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 31247 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 31276 (apache2)
      Tasks: 11 (limit: 9442)
     Memory: 22.8M
     CGroup: /system.slice/apache2.service
             ├─31276 /usr/sbin/apache2 -k start
             ├─31278 /usr/sbin/apache2 -k start
             ├─31279 /usr/sbin/apache2 -k start
             ├─31280 /usr/sbin/apache2 -k start
             ├─31281 /usr/sbin/apache2 -k start
             └─31284 /usr/sbin/apache2 -k start

Jul 08 00:10:04 app-vdam systemd[1]: Starting Apache 2.4 HTTP Server...
Jul 08 00:10:04 app-vdam systemd[1]: Started Apache 2.4 HTTP Server.

If the status shows “active (running),” it means Apache 2.4 on Ubuntu 22.04 has been successfully installed and is operational.

PHP application with Apache 2.4 web server

In Apache we can use a built-in module called mod_php to process PHP code directly within the Apache process.

But first you need to install Apache web server package, PHP, and Apache PHP, this time we use php version 7.4, you can use the other php versions.

samm@apache:~$ sudo apt install libapache2-mod-php7.4

Enable mod_php module:

samm@apache:~$ sudo a2enmod php7.4

Restart Apache web server after the configuration.

samm@apache:~$ sudo systemctl restart apache2

Step 5: Configure Firewall on Ubuntu 22.04

To allow external traffic to access your web server, you need to configure the firewall. Use ufw (Uncomplicated Firewall) to enable the necessary ports:

samm@apache:~$ sudo ufw allow http
samm@apache:~$ sudo ufw allow https
samm@apache:~$ sudo ufw reload

Or you can just allow “Apache Full”

samm@apache:~$ sudo ufw allow 'Apache Full'

The “Apache Full” profile allows both HTTP (port 80) and HTTPS (port 443) traffic.

Step 6: Test Apache Web Server

Open a web browser and enter your server’s IP address or domain name. If Apache 2.4 is functioning correctly, you should see the default Apache page.

The displayed output above provides confirmation of the successful installation and proper functioning of the Apache Web Server on Rocky Linux 9. Typically, basic Apache installations are designed to support single-page websites. For in-depth insights into setting up and deploying a Single Page Website in a production environment, we recommend exploring our comprehensive LAMP setup guide. Moving forward, the subsequent section delves into more advanced configurations within the Apache setup.

Step 7: Explore Apache Configuration

Apache’s configuration files are located in the /etc/apache2 directory. The main configuration file is apache2.conf, while site-specific configurations are stored in the sites-available and sites-enabled directories. To make changes to the configuration, use a text editor:

samm@apache:~$ sudo vi /etc/apache2/apache2.conf

Remember to restart Apache after making configuration changes:

samm@apache:~$ sudo systemctl restart apache2

Step 8: Setting Up Virtual Hosts in Apache2

Create the directory for your_domain as follows:

samm@apache:~$ sudo mkdir /var/www/sammlinux

Next, assign ownership of the directory to the user you’re currently signed in as with the $USER environment variable:

samm@apache:~$ sudo chown -R $USER:$USER /var/www/sammlinux

To ensure that your permissions are correct and allow the owner to read, write, and execute the files while granting only read and execute permissions to groups and others, you can input the following command:

samm@apache:~$ sudo chmod -R 755 /var/www/sammlinux

Next, create a sample index.html page using vim editor:

samm@apache:~$ sudo vi /var/www/sammlinux/index.html

Inside, add the following sample HTML:

<html>
    <head>
        <title>Welcome to sammlinux!</title>
    </head>
    <body>
        <h1>Success!  Welcome to sammlinux. And its working</h1>
    </body>
</html>

Save and close the file when you are finished.

Make a new one at /etc/apache2/sites-available/sammlinux.conf:

samm@apache:~$ sudo vi /etc/apache2/sites-available/sammlinux.conf

Add in the following configuration block, which is similar to the default, but updated for your new directory and domain name:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName sammlinux.com
    ServerAlias www.sammlinux.com
    DocumentRoot /var/www/sammlinux
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file when you are finished.

Now enable the file with the a2ensite tool:

samm@apache:~$ sudo a2ensite sammlinux.conf

Disable the default site defined in 000-default.conf:

samm@apache:~$ sudo a2dissite 000-default.conf

Next, test for configuration errors:

samm@apache:~$ sudo apache2ctl configtest

You should receive the following output

. . .
Syntax OK

Restart Apache to implement your changes:

samm@apache:~$ sudo systemctl restart apache2

You can test this by navigating to http://sammlinux.com

Step 9: Secure Your Website with HTTPS (Optional)

For secure data transmission, consider setting up HTTPS using SSL/TLS certificates. You can use Let’s Encrypt to obtain free SSL certificates.

Step 10: Optimize Performance

To further optimize Apache’s performance, you can adjust various settings. For instance, you can adjust the KeepAlive timeout to manage how long a connection is kept open:

samm@apache:~$ sudo vi /etc/apache2/apache2.conf

Inside the file, modify the KeepAliveTimeout value according to your requirements.

Conclusion

Installing Apache 2.4 on your Ubuntu Server 22.04 opens the door to a world of powerful web hosting capabilities. Following this step-by-step guide ensures a seamless installation process, granting you access to enhanced performance, security, and scalability. With Apache 2.4 as your web server, you’re poised to provide a robust and secure environment for hosting websites, applications, and services. Embrace the power of Apache 2.4 and propel your online presence to new heights.

Also Read Our Other Guides :

  • How To Install Apache on Rocky Linux 9
  • How To Install Apache Web Server on CentOS 7
  • How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide
  • How To Install PHP 7.4 on Ubuntu 22.04
  • How To Install MariaDB 10.6 on Ubuntu Server 22.04

Finally, now you have learned how to Install Apache on Ubuntu on your Ubuntu 22.04 Server.

Tags: ApacheLampUbuntuWebserver

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install Nextcloud with Apache and MariaDB on Ubuntu Server 22.04

Next Post

How To Install Redis on Ubuntu Server 22.04

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Install Redis on Ubuntu

How To Install Redis on Ubuntu Server 22.04

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.