Apache Ubuntu Install is one of the first tasks many Linux administrators perform when setting up a new server. Apache remains a trusted and widely used web server thanks to its flexibility, stability, and large ecosystem of modules. Whether you are hosting a personal website or deploying enterprise applications, Apache on Ubuntu 22.04 offers a reliable foundation.
In this guide, you will learn how to install Apache, configure firewall access, verify the service status, and create virtual hosts for multiple websites.
Apache is an open-source HTTP server that powers millions of websites worldwide. Ubuntu 22.04 includes Apache packages in its official repositories, making installation quick and secure.
Some major advantages include:
Because of its modular architecture, Apache works well for both small projects and large-scale deployments.
Before installing Apache, update your package list to ensure you receive the latest available packages.
Run the following commands:
sudo apt update sudo apt install apache2
Once the installation completes, Apache starts automatically in most cases.
You can confirm the service status using:
sudo systemctl status apache2
If everything is working correctly, the output should show the service as active and running.
Ubuntu systems commonly use UFW as the firewall management tool. Apache requires HTTP and HTTPS traffic to be allowed through the firewall.
Enable both ports with:
sudo ufw allow 'Apache Full'
To verify the firewall rules, run:
sudo ufw status
You should now see Apache listed with access allowed for ports 80 and 443.
This step is important because external users will not be able to access your website if the firewall blocks web traffic.
After configuring the firewall, open a browser and enter your server IP address:
http://your-server-ip
If Apache is functioning properly, the default Apache welcome page will appear.
This confirms that the web server is installed and reachable from the network.
Virtual hosts allow you to host multiple domains on a single Ubuntu server. Each website can have its own directory and configuration.
Start by creating a document root:
sudo mkdir -p /var/www/example.com
Next, create a simple test page:
sudo nano /var/www/example.com/index.html
Add basic HTML content and save the file.
Now create a virtual host configuration:
sudo nano /etc/apache2/sites-available/example.com.conf
Inside the file, define the ServerName, DocumentRoot, and log paths.
Enable the site using:
sudo a2ensite example.com.conf
Then test the configuration:
sudo apachectl configtest
If no errors appear, restart Apache:
sudo systemctl restart apache2
Your new website should now be accessible through its domain name.
Completing an Apache Ubuntu Install on Ubuntu 22.04 is a straightforward process that gives you a powerful and customizable web server environment. With firewall rules configured and virtual hosts enabled, your server is ready to host modern web applications and websites securely.
Apache continues to be a strong choice for developers, administrators, and businesses looking for dependable web hosting on Linux systems.
Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…
Introduction A self-signed SSL certificate is a certificate that is created and signed by the…
Introduction Debugging is an important part of Bash scripting. When a script does not work…
Introduction Cron jobs are used in Linux to run commands or Bash scripts automatically at…
Introduction Pipes are an important feature in Linux and Bash scripting. A pipe allows you…
Introduction The grep, awk, and sed commands are powerful text-processing tools in Linux. They are…