src/source/appinstall.rst
branchdev-dc
changeset 34 f234f01d54f9
parent 32 fd15bdd3192e
child 36 55a05201f18c
equal deleted inserted replaced
33:eeef4052fcd1 34:f234f01d54f9
     1 .. _appinstall:
     1 .. _appinstall:
     2 
     2 
     3 Installing PyAMS application
     3 Installing PyAMS application
     4 ============================
     4 ============================
     5 
     5 
     6 PyAMS default installation is based on `Buildout <http://www.buildout.org>`_ utility. It's not mandatory to use a
     6 **PyAMS** default installation is based on `Buildout <http://www.buildout.org>`_ utility.
     7 virtual environment, but it allows you to have a better control over your Python resources.
     7 
     8 
     8 .. tip::
     9 Current PyAMS version is based and validated for Python 3.5; your Python environment must also include a C
     9 
    10 compiler as well as development headers for Python, *libjpeg*, *libpng*, *libfreetype*, *libxml2*, *libxslt* and
    10     Take a look at virtualenv_. This tool provide isolated Python environments, which are more practical than installing packages systemwide.
    11 eventually *libldap*, *libpq*, *libffi*, *libgdal* or *libzmq*. *Cython* compiler can also be useful to optimize
    11     They also allow installing packages without administrator privileges.
       
    12 
       
    13 .. _virtualenv: https://virtualenv.pypa.io/en/stable/
       
    14 
       
    15 
       
    16 Current PyAMS version is based and validated for **Python 3.5**; your Python environment must also include a **C compiler**
       
    17 as well as development headers for Python, *libjpeg*, *libpng*, *libfreetype*, *libxml2*, *libxslt* and
       
    18 eventually *libldap*, *libpq*, *libffi*, *libgdal* or *libzmq*. **Cython** compiler can also be useful to optimize
    12 several packages.
    19 several packages.
    13 
    20 
    14 PyAMS default components configuration also pre-suppose that the following external tools are available:
    21 
    15 
    22 .. note::
    16 - a *Memcached* or *Redis* server, to store sessions and cache (can be changed through Beaker configuration)
    23 
    17 
    24     PyAMS default components configuration also pre-suppose that the following external services are available.
    18 Optional tools also include:
    25 
    19 
    26     * Mandatory services:
    20 - an *LDAP* server for authentication
    27 
    21 
    28        - a **ZODB shared server** (see :ref:`zodb` before). Several background processes needing a concurrent access to ZODB are started by PyAMS main process. Three ZODB storages are already provided through PyAMS: ZEO, RelStorage or Newt.db.
    22 - an *ElasticSearch* server for full text indexing (see *PyAMS_content_es* package)
    29 
    23 
    30        - a **Memcached** or **Redis*** server, to store sessions and cache
    24 - a *WebSockets* server using AsyncIO. This is used to manage notifications (see *PyAMS_notify* and *PyAMS_notify_ws*
    31 
    25   packages). An *out of the box* environment can be built using *pyams_notify* scaffold.
    32     * Optional services:
    26 
    33 
    27 
    34        - an **LDAP server** for authentication
    28 PyAMS also needs that you use a ZODB shared server, as several background processes needing a concurrent access to ZODB
    35 
    29 are started by PyAMS main process. Three ZODB storages are already provided through PyAMS: ZEO, RelStorage or Newt.db.
    36        - an **ElasticSearch server** for full text indexing (see *PyAMS_content_es* package)
    30 See :ref:`zodb` to know how to initialize database with the help of PyAMS tools.
    37 
       
    38        - a **WebSockets server** using AsyncIO. This is used to manage notifications (see *PyAMS_notify* and *PyAMS_notify_ws* packages). An *out of the box* environment can be built using *pyams_notify* scaffold.
    31 
    39 
    32 
    40 
    33 Creating initial buildout
    41 Creating initial buildout
    34 -------------------------
    42 -------------------------
    35 
    43 
    37 
    45 
    38 A simple option to install PyAMS is to create a buildout environment including *Pyramid* and all *PyAMS* packages:
    46 A simple option to install PyAMS is to create a buildout environment including *Pyramid* and all *PyAMS* packages:
    39 
    47 
    40 .. code-block:: bash
    48 .. code-block:: bash
    41 
    49 
    42     # mkdir /var/local/
    50     $ mkdir /var/local/
    43     # pip3 install virtualenv
    51     $ pip3 install virtualenv
    44     # virtualenv --python=python3.5 env
    52     $ virtualenv --python=python3.5 env
    45     # cd env
    53     $ cd env
    46     # . bin/activate
    54     $ . bin/activate
    47     (env) # pip3.5 install cookiecutter
    55     (env) $ pip3.5 install cookiecutter
    48     (env) # cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/pyams
    56     (env) $ cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/pyams
    49 
    57 
    50 *CookieCutter* will ask you for a small set of input variables that you can change or not:
    58 *CookieCutter* will ask you for a small set of input variables that you can change or not (**parameter** [*default value*]:)
    51 
    59 
    52 - **pyams_release**: version of PyAMS configuration file to use. "latest" (default value) will point to last release;
    60 - **pyams_release** [*latest*] : version of PyAMS configuration file to use. "latest" will point to last release;
    53   you can also choose to point to a given release ("0.1.4" for example)
    61   you can also choose to point to a given release ("0.1.4" for example)
    54 
    62 
    55 - **project_name**: current environment name in "human form"
    63 - **project_name** [*PyAMS*]: current environment name in "human form"
    56 
    64 
    57 - **project_slug**: "technical" package name, based on project name
    65 - **project_slug**: [*pyams*] "technical" package name, based on project name
    58 
    66 
    59 - **virtual_hostname**: Apache virtual-host name
    67 - **virtual_hostname** [*pyams.mydomain.com*]: Apache virtual-host name
    60 
    68 
    61 - **webapp_name**: web application package name ("webapp" as default)
    69 - **webapp_name** [*webapps*]: web application package name
    62 
    70 
    63 - **webapp_port**: TCP/IP port to use when running application outside Apache ("6543" as default)
    71 - **webapp_port** [*6543*]: TCP/IP port to use when running application outside Apache.
    64 
    72 
    65 - **eggs_directory**: relative or absolute path to directory containing downloaded eggs; this directory can be
    73 - **eggs_directory** [*eggs*]: relative or absolute path to directory containing downloaded eggs; this directory can be
    66   shared with other projects ("eggs" as default)
    74   shared with other projects.
    67 
    75 
    68 - **logs_directory**: absolute path to directory containing Apache's log files
    76 - **logs_directory** [*/var/log*]: absolute path to directory containing Apache's log files
    69 
    77 
    70 - **run_user**: user name under which Apache process will run ("www-data" as default)
    78 - **run_user** [*www-data*]: user name under which Apache process will run
    71 
    79 
    72 - **run_group**: group name under which Apache process will run ("www-data" as default)
    80 - **run_group** [*www-data*]: group name under which Apache process will run
    73 
    81 
    74 - **beaker_backend**: name of Beaker backend to use to store sessions and cache data ("redis" as default)
    82 - **beaker_backend** : name of Beaker backend to use to store sessions and cache data ("redis" as default)
    75 
    83 
    76 - **beaker_server**: IP address and port of Beaker backend server ("127.0.0.1:6379" as default)
    84 - **beaker_server** [*127.0.0.1:6379*]: IP address and port of Beaker backend server
    77 
    85 
    78 - **db_type**: ZODB database storage; available options include ZEO, RelStorage and NewtDB
    86 - **db_type** [*zeo*]: ZODB database storage; available options include ZEO, RelStorage and NewtDB
    79 
    87 
    80 - **db_host**: IP address of database server ("127.0.0.1" as default); WARNING: database server installation
    88 - **db_host** [*127.0.0.1*]: IP address of database server ("127.0.0.1" as default); WARNING: database server installation
    81   is not part of application installation; another "zeo_server" cookiecutter recipe is available for ZEO
    89   is not part of application installation; another "zeo_server" cookiecutter recipe is available for ZEO
    82 
    90 
    83 - **db_port**: listening port of database server ("8100" is given as default for ZEO)
    91 - **db_port** [*8100*]: listening port of database server ("8100" is given as default for ZEO)
    84 
    92 
    85 - **db_name**: database or ZEO storage name to use
    93 - **db_name** [*pyams*]: database or ZEO storage name to use
    86 
    94 
    87 - **db_username**: database user name
    95 - **db_username**: database user name
    88 
    96 
    89 - **db_password**: database password
    97 - **db_password**: database password
    90 
    98 
    91 - **zeo_realm**: ZEO authentication realm
    99 - **zeo_realm**: ZEO authentication realm
    92 
   100 
    93 - **blobs_dir**: local directory to use to store cache of ZODB blobs; cache size is limited to 10GB as default
   101 - **blobs_dir** [*/var/db/blobs*]: local directory to use to store cache of ZODB blobs; cache size is limited to 10GB as default
    94 
   102 
    95 - **use_postgresql**: specify if PostgreSQL access is required; if so, please check that PostgreSQL development files
   103 - **use_postgresql**: specify if PostgreSQL access is required; if so, please check that PostgreSQL development files
    96   are available to compile PsycoPG2 extension
   104   are available to compile PsycoPG2 extension
    97 
   105 
    98 - **use_oracle**: specify if Oracle access is required; if so, please check that Oracle development files are
   106 - **use_oracle**: specify if Oracle access is required; if so, please check that Oracle development files are
   113 
   121 
   114 - **smtp_server**: DNS name of SMTP server ("localhost" as default)
   122 - **smtp_server**: DNS name of SMTP server ("localhost" as default)
   115 
   123 
   116 - **smtp_server_name**: "human" name given to SMTP server ("pyams" as default)
   124 - **smtp_server_name**: "human" name given to SMTP server ("pyams" as default)
   117 
   125 
   118 - **pyams_scheduler**: TCP/IP address and port to use to access PyAMS tasks scheduler process ("127.0.0.1:5555" as
   126 - **pyams_scheduler** [*127.0.0.1:5555*]: TCP/IP address and port to use to access PyAMS tasks scheduler process (see :ref:`pyams_scheduler`)
   119   default); see :ref:`pyams_scheduler`
   127 
   120 
   128 - **start_scheduler** [*True*]: boolean value to indicate if scheduler process is started by this application instance
   121 - **start_scheduler**: boolean value to indicate if scheduler process is started by this application instance
   129 
   122 
   130 - **pyams_medias_converter** [*127.0.0.1:5556*]: TCP/IP address and port to use to access PyAMS medias converter process (see :ref:`pyams_media`)
   123 - **pyams_medias_converter**: TCP/IP address and port to use to access PyAMS medias converter process ("127.0.0.1:5556"
   131 
   124   as default); see :ref:`pyams_medias`
   132 - **start_medias_converter** [*True*]: boolean value to indicate if medias converter process is started by this application
   125 
       
   126 - **start_medias_converter**: boolean value to indicate if medias converter process is started by this application
       
   127   instance
   133   instance
   128 
   134 
   129 - **pyams_es_indexer**: TCP/IP address and port to use to access PyAMS Elasticsearch indexer process ("127.0.0.1:5557"
   135 - **pyams_es_indexer** [*127.0.0.1:5557*] : TCP/IP address and port to use to access PyAMS Elasticsearch indexer process  (see :ref:`pyams_content_es`)
   130   as default); see :ref:`pyams_content_es`
       
   131 
   136 
   132 - **start_es_indexer** boolean value to indicate if Elasticsearch indexer process is started by this application
   137 - **start_es_indexer** boolean value to indicate if Elasticsearch indexer process is started by this application
   133   instance
   138   instance
   134 
   139 
   135 - **use_notifications**: specify if PyAMS notifications services are to be used (see :ref:`pyams_notify`)
   140 - **use_notifications**: specify if PyAMS notifications services are to be used (see :ref:`pyams_notify`)
   136 
   141 
   137 - **pyams_ws_notify**: TCP/IP address and port of PyAMS websockets server managing notifications service
   142 - **pyams_ws_notify** [*127.0.0.1:8081*]: TCP/IP address and port of PyAMS websockets server managing notifications service
   138   ("127.0.0.1:8081" as default)
       
   139 
   143 
   140 - **lexicon_languages**: NLTK lexicon languages to use ("en:english fr:french" as default)
   144 - **lexicon_languages**: NLTK lexicon languages to use ("en:english fr:french" as default)
   141 
   145 
   142 - **extension_package**: name of a PyAMS extension package to include in environment configuration
   146 - **extension_package**: name of a PyAMS extension package to include in environment configuration
   143 
   147 
   144 - **need_pyams_gis**: specify if PyAMS GIS features are to be used by given extension package; if so, please check
   148 - **need_pyams_gis**: specify if PyAMS GIS features are to be used by given extension package; if so, please check
   145   that *libgdal* development files are available; on Debian (and maybe others), you have to specify environment
   149   that *libgdal* development files are available; on Debian (and maybe others), you have to specify environment
   146   variables (see below).
   150   variables (see below).
   147 
   151 
   148 
   152 .. tip::
   149 Boolean values accept "true", "yes", "on" or "1" (in any case) as *true* values, and anything else as *false*; setting
   153 
   150 any option to empty string will keep the default proposed value.
   154     1. Setting any option to empty string will keep the default proposed value.
       
   155     2. Boolean values accept "true", "yes", "on" or "1" (in any case) as *true* values, and anything else as *false*;
   151 
   156 
   152 You can then check, and eventually update, the proposed Buildout configuration file *buildout.cfg*, to add or remove
   157 You can then check, and eventually update, the proposed Buildout configuration file *buildout.cfg*, to add or remove
   153 packages or update settings to your needs. Then finalize Bootstrap initialization:
   158 packages or update settings to your needs.
   154 
       
   155 .. code-block:: bash
       
   156 
       
   157     (env) # python3.5 bootstrap.py
       
   158     (env) # ./bin/buildout
       
   159 
   159 
   160 This last operation can be quite long, as many packages have to downloaded, compiled and installed in the virtual
   160 This last operation can be quite long, as many packages have to downloaded, compiled and installed in the virtual
   161 environment. If you encounter any compile error, just install the required dependencies and restart the buildout.
   161 environment. If you encounter any compile error, just install the required dependencies and restart the buildout.
   162 
   162 
   163 Some dependencies can require the definition of custom environment variables before running *buildout*, like:
   163 Some dependencies can require the definition of custom environment variables before running *buildout*, like:
   164 
   164 
   165 - for *libgdal*, which is required by **PyAMS_gis** package, use:
   165 - for *libgdal*, which is required by **PyAMS_gis** package, use:
   166 
   166 
   167 .. code-block:: bash
   167 .. code-block:: bash
   168 
   168 
   169     (env) # export C_INCLUDE_PATH=/usr/include/gdal
   169     (env) $ export C_INCLUDE_PATH=/usr/include/gdal
   170     (env) # export CPLUS_INCLUDE_PATH=/usr/include/gdal
   170     (env) $ export CPLUS_INCLUDE_PATH=/usr/include/gdal
   171 
   171 
   172 **WARNING**: you have to check also that your *libgdal* release is matching "GDAL" release given in PyAMS
   172 
       
   173 .. WARNING::
       
   174     You have to check also that your *libgdal* release is matching "GDAL" release given in PyAMS
   173 configuration file (actually 2.1.0).
   175 configuration file (actually 2.1.0).
   174 
   176 
   175 - for *cx_Oracle*, which is required if you use Oracle database connections, use:
   177 - for *cx_Oracle*, which is required if you use Oracle database connections, use:
   176 
   178 
   177 .. code-block:: bash
   179 .. code-block:: bash
   178 
   180 
   179     (env) # export ORACLE_HOME=/usr/lib/oracle/12.1/client64
   181     (env) $ export ORACLE_HOME=/usr/lib/oracle/12.1/client64
   180 
   182 
   181 These examples are given for Debian GNU/Linux. You may have to adapt configuration based on your own Linux
   183 These examples are given for Debian GNU/Linux. You may have to adapt configuration based on your own Linux
   182 distribution and packages versions.
   184 distribution and packages versions.
   183 
   185 
       
   186 
       
   187 **Then finalize Bootstrap initialization:**
       
   188 
       
   189 
       
   190 .. code-block:: bash
       
   191 
       
   192     (env) $ python3.5 bootstrap.py
       
   193     (env) $ ./bin/buildout
   184 
   194 
   185 Environment settings
   195 Environment settings
   186 --------------------
   196 --------------------
   187 
   197 
   188 The project generated from *pyams* scaffold is based on default Pyramid's *zodb* scaffold, but it adds:
   198 The project generated from *pyams* scaffold is based on default Pyramid's *zodb* scaffold, but it adds:
   205 
   215 
   206 *development.ini* and *production.ini* files contain many commented directives related to PyAMS components. Read and
   216 *development.ini* and *production.ini* files contain many commented directives related to PyAMS components. Read and
   207 update them carefully before initializing your application database!
   217 update them carefully before initializing your application database!
   208 
   218 
   209 
   219 
   210 Initializing the database
   220 Initializing the ZODB database
   211 -------------------------
   221 =========================
   212 
   222 
   213 When you have downloaded and installed all required packages, you have to initialize the database so that all
   223 After, you have downloaded and installed all required packages, you have to initialize the database so that all
   214 required components are available.
   224 required components are available.
   215 
   225 
   216 From a shell, just type:
   226 From a shell, just type:
   217 
   227 
   218 .. code-block:: bash
   228 .. code-block:: bash
   219 
   229 
   220     (env) # ./bin/pyams_upgrade etc/development.ini
   230     (env) $ ./bin/pyams_upgrade etc/development.ini
   221 
   231 
   222 This process requires that every package is correctly included into *pyramid.includes* directive from selected
   232 This process requires that every package is correctly included into *pyramid.includes* directive from selected
   223 configuration file.
   233 configuration file.
   224 
   234 
   225 
   235 
   226 Initializing Elasticsearch index
   236 Initializing Elasticsearch index
   227 --------------------------------
   237 ================================
   228 
   238 
   229 If you want to use an Elasticsearch index, you have to initialize index settings and mappings; the Ingest attachment
   239 If you want to use an Elasticsearch index, you have to initialize index settings and mappings; the Ingest attachment
   230 plug-in is also required to handle attachments correctly.
   240 plug-in is also required to handle attachments correctly.
   231 
   241 
   232 Elasticsearch integration is defined through the *PyAMS_content_es* package. Configuration files are available in this
   242 Elasticsearch integration is defined through the *PyAMS_content_es* package. Configuration files are available in this
   233 package, for attachment pipeline, index settings and mappings:
   243 package, for attachment pipeline, index settings and mappings:
   234 
   244 
   235 .. code-block:: bash
   245 .. code-block:: bash
   236 
   246 
   237     (env) # cd /var/local/src/pyams/pyams_content_es
   247     (env) $ cd /var/local/src/pyams/pyams_content_es
   238     (env) # curl --noproxy localhost -XDELETE http://localhost:9200/pyams (1)
   248     (env) $ curl --noproxy localhost -XDELETE http://localhost:9200/pyams (1)
   239     (env) # curl --noproxy localhost -XPUT    http://localhost:9200/pyams -d @index-settings.json
   249     (env) $ curl --noproxy localhost -XPUT    http://localhost:9200/pyams -d @index-settings.json
   240 
   250 
   241     (env) # curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfNewsEvent/_mapping -d @mappings/WfNewsEvent.json
   251     (env) $ curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfNewsEvent/_mapping -d @mappings/WfNewsEvent.json
   242     (env) # curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfTopic/_mapping -d @mappings/WfTopic.json
   252     (env) $ curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfTopic/_mapping -d @mappings/WfTopic.json
   243     (env) # curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfBlogPost/_mapping -d @mappings/WfBlogPost.json
   253     (env) $ curl --noproxy localhost -XPUT    http://localhost:9200/pyams/WfBlogPost/_mapping -d @mappings/WfBlogPost.json
   244 
   254 
   245 (1) If 'pyams' is defined as Elasticsearch index name.
   255 (1) If 'pyams' is defined as Elasticsearch index name.
   246 
   256 
   247 
   257 
   248 NLTK initialization
   258 Initializing NLTK
   249 -------------------
   259 =================
   250 
   260 
   251 Some NLTK (Natural Language Toolkit) tokenizers and stopwords utilities are used to index fulltext contents elements.
   261 Some NLTK (Natural Language Toolkit) tokenizers and stopwords utilities are used to index fulltext contents elements.
   252 This package requires downloading and configuration of several elements which are done as follow:
   262 This package requires downloading and configuration of several elements which are done as follow:
   253 
   263 
   254 .. code-block:: bash
   264 .. code-block:: bash
   255 
   265 
   256     (end) # ./bin/py
   266     (end) $ ./bin/py
   257     >>> import nltk
   267     >>> import nltk
   258     >>> nltk.download()
   268     >>> nltk.download()
   259     NLTK Downloader
   269     NLTK Downloader
   260     ---------------------------------------------------------------------------
   270     ---------------------------------------------------------------------------
   261         d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
   271         d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
   297 Pyramid application), '*/usr/share/nltk_data*', '*/usr/local/share/nltk_data*', '*/usr/lib/nltk_data*' and
   307 Pyramid application), '*/usr/share/nltk_data*', '*/usr/local/share/nltk_data*', '*/usr/lib/nltk_data*' and
   298 '*/usr/local/lib/nltk_data*'.
   308 '*/usr/local/lib/nltk_data*'.
   299 
   309 
   300 
   310 
   301 Starting the application
   311 Starting the application
   302 ------------------------
   312 ========================
   303 
   313 
   304 When database upgrade process has ended, you can start the web application process with the standard Pyramid's
   314 When database upgrade process has ended, you can start the web application process with the standard Pyramid's
   305 *pserve* command line tool:
   315 *pserve* command line tool:
   306 
   316 
   307 .. code-block:: bash
   317 .. code-block:: bash
   308 
   318 
   309     (env) # ./bin/pserve etc/development.ini
   319     (env) $ ./bin/pserve etc/development.ini
   310 
   320 
   311 In standard debug mode, all registered components are displayed in the console, until the final line (here using ZEO):
   321 In standard debug mode, all registered components are displayed in the console, until the final line (here using ZEO):
   312 
   322 
   313 .. code-block:: bash
   323 .. code-block:: bash
   314 
   324 
   377 
   387 
   378 
   388 
   379 From this point, you can launch a browser and open URL *http://127.0.0.1:6543/admin* to get access to PyAMS
   389 From this point, you can launch a browser and open URL *http://127.0.0.1:6543/admin* to get access to PyAMS
   380 management interface; default login is "admin/admin", that you may change as soon as possible (see
   390 management interface; default login is "admin/admin", that you may change as soon as possible (see
   381 :ref:`pyams_security`)!!.
   391 :ref:`pyams_security`)!!.
       
   392