Skip to content

Production environment

Shared Account edited this page Dec 6, 2018 · 9 revisions

Production environment information

OS and runtimes

  • Ubuntu 18.04 or 16.04 LTS
  • PHP7.x or PHP5.6 Ondrej PHP repository
  • nodejs (latest version expted but optional)

Please note

  1. Instances are accessible using private key under user ubuntu
  2. Web code is running under user www-data
  3. CRONS to be run under user ubuntu
  4. Users are logged under user ubuntu (should use when troubleshooting only, any modification must be done on dev instances with Q/A)
  5. System web root document is located in /var/www/'
  6. Application production settings is stored in opsworks.php under each deploy directory (see belows under Deploy Phases)

Deploy strategy

The deployment follows Caspistrano, the workflow is:

In the deploy directory, a sub-directory named shared must be created. This sub-directory is where configuration and temporary files will be kept. A typical Oxi Web application might have config, log, tmp, and cache_lp directories within the shared directory to keep the files stored there independent of the code in the source repository.

In addition to the shared sub-directory, the deploy process will create sub-directories named releases and current (also in the deploy directory). The release directory holds (up to) five most recently deployed versions of an application. The current directory holds the currently-released version.

For example:

deploy_directory/
  current/
  releases/
  shared/
    config/
    log/
    cache_lp/
    tmp/

deploy directory follows web application domain name, with . replaced by ``.

For example:

An application with domain name a-webapp.example.com will have

deploy directory names a-webappexamplecom and located under /var/www/a-webappexamplecom

or an application with domain name beauty.bioelite.ro will have

deploy directory names beautybioelitero and located under /var/www/beautybioelitero

Deploy Phases

In short, a deployment happens in several phases:

  1. Checkout - fetch a application revision, mostly using git
  2. Hooks - contains tasks like correct application revivision permissions in deploy directory, create configure settings for application, in this case, ospworks.php, initiating the database if specified, then symlink latest revision in releases directoryto current directory. If there is any additional task, it goes here.
  3. Restart - reload NGINX to get new web site configuration and restart php-fpm to load new application revision.

While deploying, a opsworks.php is created and placed under deploy directory, and filled with production environment DB settings. If code is deployed to deploy, then its located at /var/www/deploy/current/opsworks.php.

The opsworks.php contents can be viewed here: opsworks.php

Any NGINX's rewrite rules must be put in a filename app.rules and commit to the root of application repository, it helps deploy machine to populate them in application NGINX configuration file.

An example of app.rules file:

rewrite ^([^.]*[^/])$ $1/ permanent;
rewrite ^/forms/([a-z0-9-]+)/$ /index.php?action=$1 last;
rewrite ^/redirect/([a-z0-9-]+)/$ /index.php?action=$1 last;

All application should refer to settings provided by this file to avoid hard-code in application revision

How to deploy?

All web application should be deployed from here Deploy Center

Steps

  1. Log in to https://deploycenter.linuxserv.space
  2. Go to Templates under Resources in the left
  3. Select appropriate application template in the right, application template name follows application domain name, such as example.com
  4. Click the Rocket icon to deploy
  5. If the deployment returns green then it's done successful, and changes by new revision should be applied.
  6. If you have any problem while deploying, please contact sysadmin