Former winger Solari was appointed to replaced Julen Lopetegui, who was sacked on Monday after only 14 games.
Karim Benzema, Marco Asensio, Alvaro Odriozola and Cristo Gonzalez were on the scoresheet for the La Liga side.
Melilla is a tiny Spanish enclave of about 4.7 square miles on the north coast of Morocco.
It has a population of 86,000, with the game taking place at a packed Alvarez Claro Stadium which has a capacity of 10,000.
The second leg will be 460 miles away at Real’s Santiago Bernabeu on 5 December.
Former Argentina international Solari “provisionally” stepped up from Real’s Castilla B team, although Spanish regulations state an interim coach can be at the helm for a fortnight – but must be appointed officially after 15 days, or not at all.
During that period, the 52-year-old has games against Valladolid – sixth in La Liga – on Saturday, Group G’s bottom side Viktoria Plzen in the Champions League on 7 November, and mid-table Celta Vigo the following Sunday.
Real have earned 14 out of a possible 30 league points this season and have taken only one from their past five matches – their worst run since they were pointless in the final five games of 2008-09 under Juande Ramos.