How to install Apache on Ubuntu?

Submitted by sysop on Sun, 05/21/2023 - 21:57

Apache, also known as Apache HTTP Server. It is the most widely used open-source web server software. It is developed and maintained by the Apache Software Foundation. Apache is a powerful and flexible server that allows hosting websites, serving web pages, and handling HTTP requests.

To install Apache on Ubuntu, you can follow these steps:

  1. Update System Packages: Before installing any new software, it's recommended to update the package lists and upgrade existing packages. Open the terminal and run the following commands:
    sudo apt update
    sudo apt upgrade
  2. Install Apache: Once the system is up to date, you can proceed with installing the Apache web server by running the following command:
    sudo apt install apache2
  3. Start and Enable Apache: After the installation is complete, Apache should start automatically. However, you can ensure that Apache starts on system boot by running the following command:
    sudo systemctl enable apache2
  4. Verify Apache Installation: To confirm that Apache is running properly, open a web browser and enter the following URL:
    http://localhost/

    If Apache is installed correctly, you should see the default Apache2 Ubuntu Default Page.

  5. Firewall Configuration: If you have a firewall enabled on your system, you need to allow incoming traffic on port 80 (HTTP) to access the web server. You can use the following command to enable HTTP traffic:
    sudo ufw allow 'Apache'
  6. Apache Configuration Files: The main configuration file for Apache is located at /etc/apache2/apache2.conf. You can make modifications to this file or add additional configuration files in the /etc/apache2/conf-available/ directory.
     
  7. Managing Apache Service: You can use the following commands to manage the Apache service:
  • Start Apache:
    sudo systemctl start apache2
  • Stop Apache:
    sudo systemctl stop apache2
  • Restart Apache:
    sudo systemctl restart apache2
  • Check Apache status:
    sudo systemctl status apache2


That's it! You have successfully installed Apache on your Ubuntu system. You can now start configuring Apache and hosting your websites or web applications.