With the info you gave as I understand that you have installed everything from apt, so no special configuration is running.
This makes me consider on which can be the point with more chances to be the bottleneck. And no offense, but probably is the php code, if the apt repos had a bad config there will be more people with the same issue.
So , what do you need is to debugg a bit your code, and that is not fun.
You may try 'mtop', it's a 'top' or 'htop' tool to look inside the mysql server, with this you'll be able to know which queries are taking more time.
Also, if mysql its in a different server and you don't use dns it usually adds 20 seconds to your queries, sounds weird but it happend to me a month ago.
If nothing of what i've said helps, please explain yourself a bit longer. thanks.