I know similar questions have been asked. But also, consider that I want to publish a book in countries other than the US or UK.
It depends on how lax copyright laws and enforcement are in your country.
A number of unofficial Harry Potter novels have appeared in non-English-speaking countries, to cash in on the craze. Some of these may be parodies.
Here's a list, some of the titles are pretty off the wall.
You can't publish a book explicitly set in a world created by another author without appropriate permissions, which you will not get.
Most authors and publishers turn a blind eye to fan fiction AS LONG AS IT IS NOT MONETIZED. But the moment you try to make money from this, you are stealing someone else's intellectual property.
With that said, Harry Potter didn't invent the idea of a magical world or magical school. You could certainly publish a book about a magic world existing alongside the mundane one, as long as Harry Potter characters and settings don't make appearances. No schools named "Hogwarts" or "Beauxbatons." Use HP as an inspiration --don't copy it.