@leginhee Have you tried to change the datadirectory Property in config.php dynamically depending on which php interface is running? See my answer in a similar thread. This works for UI and for occ commands. I couldn’t figure it out though, how to get rid of the message of the problem&security scanner.
Update: changing the config.php files is not supported, but in the thread mentioned above I found and linked a solution that works also over app updates etc.