There's no need for Apache to know about ejabberd's database — why should it?
Instead, you code your website as usually and then hook ejabberd up to it to provide the chat functionality using BOSH (for instance, via Strophe.js or something other. "Full-blown" web chat clients exist as well — there are hordes of them (plus just search the web).
There will be the problem of user authentication/registration but you can either have transient users (if you unly need public chats (rooms) or make ejabberd use the same MySQL database the website engine uses — ejabberd can do that. Another solution is to enable external authentication in ejabberd — where it uses a program (written by you) to authenticate its users; such a program is then free to query the same database the website engine uses which solves the problem of imposing a specific schema in the data base. Another bonus is that it's easier to change the database backend when needed.