How to configure WordPress to be a subdirectory of my main site as mymainsite.com/blog?

On the admin panel, under Settings -> General Settings, make sure the “WordPress Address (URL)” and “Site Address (URL)” are correct. Also, check out the WordPress StackExchange.