Mainly tap from the ends of the nut. A few gentle taps on the sides can help free the glue bond there, but tap very gently indeed when tapping towards the headstock, as it’s very easy to hit it too hard and the end of the fretboard can break off. If it does, then you can normally glue it back on (do it straight away so you don’t lose any bits).
Best to mask off around the nut to minimise damage if you slip with the hammer.