- Log in to the Server
 
- Verify Nginx Service Status: sudo systemctl status nginx
 
- Check Which Service is Listening on Port 80 : sudo lsof -i :80
 
(Apache2 service was found to be running and occupying port 80, which conflicted with Nginx.)
- Disable Apache2 Service :
 
   ( Stop and disable the Apache2 service to free up port 80)
 
sudo systemctl stop apache2
sudo systemctl disable apache2
- Enable and Verify Nginx on Port 80
( Ensure that Nginx is configured to listen on port 80 and restart the service) 
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl restart nginx
- Verify that Nginx is now listening on port 80 : sudo lsof -i :80
 
- If the website still displays a 502 Bad Gateway error, check the Nginx error logs:
 
/var/log/nginx/error.log
- If the logs indicated a PHP-related issue where the PHP-FPM service was stopped.
 
sudo systemctl start php-fpm
sudo systemctl enable php-fpm