On apache you need to edit security.conf:
nano /etc/apache2/conf-enabled/security.conf
and set:
Header set X-Frame-Options: "sameorigin"
Then enable mod_headers:
cd /etc/apache2/mods-enabled
ln -s ../mods-available/headers.load headers.load
And restart Apache:
service apache2 restart
And voila!