A magnitude 5.8 earthquake struck off the western Philippines, with tremors felt in the capital.