What are the steps for a foreigner to reside in morocco legally?

What are the steps for a foreigner to reside in morocco legally?

1- get a visa if he needs one

2- get an address with a written legalized lease

3- open a bank account

4- prove he can sustain himself (company with contrats / invoices or work contract approved by the Ministry or 100.000 MAD on his account)

5- provide a police record from his country

@mmrabet128 reasonable income and accomodation are the requirements for residenccy in morocco.