Alister West

home is where your code is ...

LAMP Deployment Best Practices

LAMP stack setup best practices

Secrets - not in codebase

Secrets (like db passwords) should not be kept in your apps codebase.
Keep these in a file that your app can read.

~/.parameters/database.yml

Environment Configuration - allow overrides

Production configuration will be different from staging, should be different from dev.
Allow overrides that are generated outside your codebase and allow the ability to choose env.
Can be combined with 'Secrets' above.

~/myapp --config=~/.paramaters/app1.production.yml

Static Assets

There are 3 types of static assets:
1. source in codebase       - eg. /static/images/mylogo.png
2. generated from codebase  - eg. /static/css/all.css
3. dynamic from application - eg. /data/report.pdf

Application data (3) should be kept outside the web-root for ease of backups/replication/deployment.
Generated files (2) should not be in codebase to keep massive diffs from cluttering your RCS. 
Static files (1) should be able to be versioned and redirect friendly. eg. "myfile.txt?v123" or "/v123/myfile.txt"

Frontend Cache/Proxy Server

Nginx, Varnish, Apache can be configured for high-performance static file serving.
This will be faster than your webapp so use a frontend cache/proxy server for this purpose.
When using Apache + mod_perl/mod_php child-processes can become bloated. Have a seperate Apache for static requests.
By Alister West