Directory structure

Once logged in via SSH/SCP/FTP, you will soon familiarise yourself with the directory hierarchy.

/microcloud/backups_ro

  |-mysql
  |---monthly
  |---weekly
  |---daily
  |-lost+found
  |-domains
  |---latest
  |---2013-05-05
  |---2013-05-06
  |---2013-05-07

This directory is read-only and contains your domain backups and database backups.

! 3 days of incremental file backups are kept ! 7 days of database backups are kept

After which, both are rotated.

Outside of the /microcloud directory – you may do whatever you please. But bear in mind your disk space is shared with the host system. So keep an eye on dh -h or your Munin Graphs

/microcloud/logs_ro

 |-dh[0-9]+
 |---monit-YYYY-MM-DD.log.gz
 |---ovpn-client-server-YYYY-MM-DD.log.gz
 |---monit-YYYY-MM-DD.log.gz
 |-lb[0-9]+
 |---dos-filter-YYYY-MM-DD.log
 |---haproxy-YYYY-MM-DD.log.gz
 |---monit-YYYY-MM-DD.log.gz
 |-web[0-9]+
 |---php-error-YYYY-MM-DD.log.gz
 |---php-slow-YYYY-MM-DD.log.gz
 |---php-access-YYYY-MM-DD.log.gz
 |---nginx-access-YYYY-MM-DD.log.gz
 |---nginx-error-YYYY-MM-DD.log
 |---monit-YYYY-MM-DD.log.gz
 |-db[0-9]+
 |---mysql-error-YYYY-MM-DD.log.gz
 |---mysql-slow-YYYY-MM-DD.log.gz
 |---monit-YYYY-MM-DD.log.gz
 |-mail[0-9]+
 |---dkim-filter-2014-05-10.log.gz
 |---postfix-YYYY-MM-DD.log.gz
 |---monit-YYYY-MM-DD.log.gz

This directory is read-only. It contains all necessary logs for your domains. The log files are rotated on a daily basis and kept for 7 days. Logs are also centrally logged with a web interface.

The log files are gzip compressed, so to view the file, you must decompress the file.

Eg. To view the last 10 lines of the Nginx access log file for today, use zcat

zcat /microcloud/logs_ro/web*/nginx-access-$(date +%F).log.gz | tail -n 10

Eg. View the Nginx access log file for a specific IP address, use zgrep

zgrep '127.0.0.1' /microcloud/logs_ro/web*/nginx-access-$(date +%F).log.gz

/microcloud/domains

  |-example
  |---lib64
  |---sbin
  |---lib
  |---home
  |---tmp
  |---dev
  |---usr
  |---var
  |---logs
  |---version
  |---bin
  |---domains
  |---example.com
  |-----___general
  |-------example.com.conf
  |-------example.com.location.semi-static.conf
  |-------example.com.location.static.conf
  |-----___maintenance
  |-------example.com.access.conf
  |-----___rewrites
  |-------example.com.conf        
  |-----http
  |-----maintenance
  |-----www     
  |---etc

This directory is read-write and contains all the files for your web site. Websites can be combined into a single group if they have commonality – or otherwise can be grouped individually.

The group defines the chroot jail that the domains will operate from. This provides another level of security so that the PHP-FPM process (runs as www-data) cannot escape its operating directory. It protects groups from each other and still allows for very simple file permissions management (ie. everything owned by www-data 33:33).

Four key directories are created as standard:

example.com         
  http             represents any traffic sent to http://example.com
  maintenance      is a special directory for when maintenance mode is turned on
  ___general       is a special directory for Nginx configuration includes
  ___maintenance   is a special directory for Nginx configuration includes
  ___rewrites      is a special directory for Nginx configuration includes

If your domain was configured with wildcard support (default), then adding new sub-domains is very straightforward, just create a new directory in the group/domains/domainname directory.

Eg. /microcloud/domains/example/domains/example.com/mynewsubdomain

You can also symlink directories to another, an example would be to serve the media and skin directories from subdomains – but still retain the standard Magento folder hierarchy.

cd /microcloud/domains/example.com
ln –s www/media media 
ln –s www/skin skin

! Symlinks must be relative and not absolute
! www is symlinked to http by default, www => http
! The http directory represents the non-subdomain variant of your domain (ie. http://example.com)
! The differentiation between ___general and ___rewrites is that the general config include is defined in the server { } scope for the vhost – whereas the rewrite config include is defined in the location / { } scope.


! Try not to put anything in the /microcloud directory other than the website files themselves; this helps keep file clutter to a minimum.
! There are no resource limits applied to the access server by default, it can utilise 100% RAM, CPU or DISK space – so work with caution.