在同一台计算机上开发和访问生产主机

Problem is that the development is running same domain like example.com as the production server due to the facebook auth usage.

I can not set the development to different port as the facebook redirects to wrong url.

I am using LAMP stack and the development version domain url is set in /etc/hosts

You can try setting up virtualhosts and using the hosts file to override the DNS so that those domains point to 127.0.0.1