I have an ExpressionEngine site set up with Git in multiple environments: Local, Development, and Production.
I have a couple of directories that are above web root, so the web root directory itself is inside the git repo, like this:
- .git
- system
- third_party
- templates
- public_html (web root)
- assets
- css
- js
- img
- themes
- index.php
- assets
Now, my development and production environments are with 2 separate hosting providers, and their web roots have different names from each other. Development, for example, is named public_html, but Production is named content.
How do I deploy to both of these environments when the web root directories have different names?
Using symbolic links on the server to point the web root to the appropriate directory is a time honored technique. Let’s assume you gave your Git Repo an obvious name: clientsite.com, so inside that folder you have:
That folder gets uploaded to your staging/production servers. On the staging server, you would then create a symbolic link to web_root named public_html:
ln -s clientsite.com/web_root public_htmlAnd then on the production server, you would make a symbolic link to web_root called content:
ln -s clientsite.com/web_root contentNow, what’s brilliant about this is that if you are very clever and are using MSM, you can create config.php and index.php files that allow you to use web_root for ALL your domains in that EE installation and just create symbolic links to it for each site. For example:
Then in index.php, you look at the HTTP_HOST server config to set the site_name:
Finally, your config.php can do something very similar:
In this way, you can have global config options and then site specific options too.