Optima's batteries don't release gasses. They are completely sealed.
As far as the mounting the battery in the box thing goes, it wouldn't be my ideal location, and I'd probably exhaust all other options first. However, if it's the only place to go with, what are you going to do? First, I would make sure that the displacement of the battery isn't going to throw off your box dimensions too much. Pull the sub from the box and maybe temp install the batt in the box to get a real world impression on how it will affect the sound. If that's all good, install the battery very securely in the box, be sure to seal up the holes for the cables really well. To be safe after all that, maybe pull the sub and check the install out once a week for awhile, gradually increasing time in between checks. I really wouldn't recommend doing what you are thinking. If there is no other place for it, maybe look into modding the spare tire well and install a battery box in it. Even if it would mean cutting out the sheet metal and having it stick out from under the car a few inches, I think that would be a better route than putting it in the box.