Installation
Update Package Index
Before installing any package, it's recommended to update the package index to ensure you have access to the latest available packages and their dependencies
sudo apt update
Install Apache
Use the following command to install the Apache package
sudo apt install apache2
Verify Installation
After the installation is complete, you can verify if Apache is running by accessing the default Apache landing page in your web browser. Open a web browser and navigate to http://localhost or http://server_ip_address.
If you see the Apache default landing page, it means the installation was successful
Managing Apache Service
Apache is installed and runs as a system service. You can manage the Apache service using the following commands
Start Apache service
sudo systemctl start apache2
Stop Apache service
sudo systemctl stop apache2
Restart Apache service
sudo systemctl restart apache2.
Check Apache service status
sudo systemctl status apache2.
Firewall
If you have a firewall enabled on your Ubuntu system (such as UFW), you'll need to allow incoming HTTP and HTTPS connections. Run the following commands to allow Apache through the firewall
sudo ufw allow 'Apache'
sudo ufw allow 'Apache Full'
These commands will open ports 80 (HTTP) and 443 (HTTPS) for incoming traffic