I have a web application that has the following directory structure:
/subdomain_name
/app
/public
This web application is installed for every new user in our VPS. They provide a subdomain name, and then a subdomain is generated, with the corresponding directory in the VPS where the web app will be stored. Every web app consists of two directories, app and public.
What I need is, for public to be, well, public, so that when the user types http://subdomain_name.ourdomain.com, the contents of public are shown to the user. At the same time, the app directory, which is on the same level as public, MUST NOT BE ACCESSIBLE to any user.
How would I go about this?
Keep in mind that the solution must be capable of being automated (every step done programmatically). I'm not asking for the automatization how-to, but the solution should be able to be executed programmatically for each web app installation, not just manually.
Additional info: Using Apache and cPanel.
EDIT for clarification: I'd like to be able to pull off a structure like the following:
/the hosting home directory
/some_directory
/some_other_directory
/public_html
[here goes ourdomain.com's index and such]
/webapp_charles
/app
/public
/webapp_fred
/app
/public
/webapp_john
/app
/public
So, for example, user types http://webapp_charles.ourdomain.com into the browser and /[our hosting home]/webapp_charles/public is loaded. However, no visitor must be able to access /[our hosting home]/webapp_charles/app.