How did the Portuguese establish footholds on the coasts of Africa?

By building small forts and trading post's. from the West of Africa, they sailed arouond the continet, and continued to establlish forts and trading posts, but they also attacked coastal cities of East Africa, such as Mombasa and Malindi, which were hubs of international trade.