Step-by-Step Guide
Connect to Your EC2 Instance via SSH
Replace /path/to/your-key.pem with the path to your SSH key, and your-ec2-instance-public-dns with the public DNS of your EC2 instance.
ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns
Restart Apache
Once connected to your EC2 instance via SSH, you can restart Apache using the following command:
sudo systemctl restart apache2
If Apache restarts successfully, you should see no output. If there are errors, they will be displayed in the terminal.
Verify Apache Status (Optional)
To verify that Apache is running without errors, you can check its status:
sudo systemctl status apache2
If Apache is running correctly, you should see an output indicating that Apache is active and running.