An inverter needs to be located close to the battery, but not in the same compartment.
Basically short 12 VDC lines and 120 VAC lines basically as long as you need.
Many modern appliances require a PSW (Pure Sine Wave) inverter to function properly.
You will need to carefully consider your 120 VAC load, inverter size and type and size of your battery bank so they fill your needs.
Said another way, too high a 120 VAC load, a lighter load run for too long before recharging the batteries, incorrect size/type inverter and/or too small a battery bank or bank that is not fully charged when you need it to perform will likely NOT meet your needs.