A user gets a subdomain in my application, customer.myapp.com. Since users will want to use their own custom domain I'll expect them to setup a CNAME record pointing customer.com to customer.myapp.com. I was hoping to avoid creating a vhost record for every customer but I think that's what I'm going to have to do. I can't quite find a definitive answer, so am I right in assuming that? If so what is the best way to go about this? Can my application programmatically edit/add vhosts? I'd like to be hands off when a customer signs up for my service. How do services like Shopify and Tumblr handle this?
Perhaps you can have some interest in mod_vhost_alias http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html. Instead of setting up each domain you set up a instruction telling apache to search for DocumentRoot of a domain in a path containing that domain name.
I've seen it done in a company I used to work for, but it wasn't set up by me. Expanding on Florian's answer a little, there's a blog post which covers how to do this and explains how it works: https://muffinresearch.co.uk/redirecting-subdomains-to-directories-in-apache/
You can either use the ServerAlias directory (it's an addon to ServerName). It takes a list of 'other' names for a vhost.
The harder-to-implement way is using mod_rewrite, which can also used for vhosts. It can be a better option if you go to the 100s or 1000s of names for a vhost. But it is rarely used. It comes with the big bonus of not needed apache reloads. Some documention is here: http://httpd.apache.org/docs/2.2/rewrite/vhosts.html
Edit: I did not think of or mention the rewritemap option: http://httpd.apache.org/docs/2.4/rewrite/rewritemap.html
I hope that the 'big services' wrote something more efficient for their use cases!