WebFaction
Community site: login faq

I have a website that needs multiple subdomains but I want to separate the CMS core and theme files from each subdomain webroot so that I have single source to apply future template changes across all subdomains.

The basic file structure of the CMS I'm using (a flat-file CMS called Statamic) is as follows:

/index.php /assets /local /site/content /site/themes /statamic

Putting these all in webroot makes the site fully functional. But then as I create more subdomains, I have all these totally independent websites that I can't manage easily. So I want to separate the subdomain's content and files from the core and theme files.

So, the directories I want to move out of the subdomain web roots are local, statamic, and site/themes. By moving these above webroot and creating a symlink for each in my subdomain app, I get a file structure that works and looks like this:

~/local ~/site/themes ~/statamic ~/my_website/index.php ~/my_website/assets ~/my_website/local // symlink ~/my_website/site/content ~/my_website/site/themes // symlink ~/my_website/statamic // symlink

Now, transitioning to WebFaction, I can't put the 3 shared directories above webroot (directly on ~/webapps/), so what can I do instead to create the same effect? Do I need a symbolic link app per subdomain? Maybe a PHP app AND symbolic link app per subdomain? Or some other configuration altogether?

I tried to put the theme and core files in a sibling folder on my local machine, but got a 403 Forbidden error from my CSS calls after symlinking. That looked like this:

~/website_core/local ~/website_core/site/themes ~/website_core/statamic ~/my_website/index.php ~/my_website/assets ~/my_website/local // symlink ~/my_website/site/content ~/my_website/site/themes // symlink ~/my_website/statamic // symlink

I had high hopes for this working because I think I could replicate it on WebFaction fairly easily (with a PHP app for core + a PHP app for subdomains). But the only way to get rid of the 403 Forbidden error on my CSS was to move that site/themes folder back up a level, out of the sibling folder.

asked 02 Jun '16, 14:47

danfo
115
accept rate: 0%

edited 06 Jun '16, 17:53


Hello,

Here's one way you can do this. Considering your current setup, I suppose you have already created a website record for the application 'php_app' that bears the primary domain 'example.com'.

For the sub-domains you can create a new and separate 'symbolic link' app for each. For example:

Domain: subdomain1.example.com

Extra info: /home/yourusername/webapps/php_app/subdomain_1_webroot/

Therefore all requests to 'subdomain1.example.com' use the content from the above absolute path.

You would do that for each additional subdomain you want to use. Hope this helps!

permanent link

answered 02 Jun '16, 22:02

NickR ♦♦
4665
accept rate: 20%

The subdomains will need to have their own content. Only the CMS config files and theme/template files will be shared among all subdomains.

I added some info to my OP to clarify... thank you for your suggestion(s)!

(02 Jun '16, 23:40) danfo

Right, the 'Extra info' field specifies the absolute path to the content of the subdomain. Also, the symbolic link app uses the PHP interpreter of your choice when you create it, so it should be all you need. Have you been able to test out my suggestion on one subdomain to see if it works with 'Statamic'?

(02 Jun '16, 23:54) NickR ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×264
×76
×15
×3

question asked: 02 Jun '16, 14:47

question was seen: 2,155 times

last updated: 06 Jun '16, 17:53

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM