Web Application Setup - Application Prerequisits

webapp

Create Application User & Directory Structure

  1. Create application user: www-appname

    ... sudo adduser www-appname --disabled-login \
                            --disabled-password \
                            --ingroup www-data \
                            --home /var/lib/www/appname \
                            --shell /bin/false
    
  2. Create application directory:

    ... sudo mkdir -p /var/www/appname
    
  3. Set ownership of this directory:

    ... sudo chown appname:www-data /var/www/appname
    

    Also add admin user access:

    # not sure what the [d:efalut] option does, but alone, that doesn't grant access
    ... sudo setfacl -R -m d:u:adminuser:rwx /var/www/appname
    # this grants access
    ... sudo setfacl -R -m u:adminuser:rwx /var/www/appname
    
  4. Create the rest of the basic directory structure:

    appname
    ├── config
    ├── data
    ├── logs
    ├── packages
    ├── static
    
  5. Install poetry

    We are going to be using poetry to manage our python app dependencies, so we need to install it. The key here is that we installed the python3.7 package - so we want to install it there:

    ... curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3.7
    

    Once installed we need to tweek the poetry environment by adding $HOME/.poetry/bin to your path.

    Open ~/.poetry/bin/poetry in an editor, and change the execution line at the top of the file from this:

    #!/usr/bin/env python
    

    to this:

    #!/usr/bin/env python3.7
    

    Lastly, we want to set up poetry to not automaticall create virtual environments:

    ...  poetry config settings.virtualenvs.create false