src/source/quickstart.rst
changeset 28 a7332a53e6dc
parent 26 7d77990df225
child 34 f234f01d54f9
equal deleted inserted replaced
23:c4d22fabf017 28:a7332a53e6dc
     1 .. _quickstart:
     1 .. _quickstart:
     2 
     2 
     3 PyAMS quickstart
     3 PyAMS Quickstart
     4 ================
     4 ================
     5 
     5 
     6 Here is a quick list of operations that you can follow to create and start your first PyAMS application from scratch.
     6 Here is a quick list of operations that you can follow to create and start your first PyAMS application from scratch.
     7 For this quick start, we will only use the most basic setup and keep several features disabled (like Elasticsearch
     7 For this quick start, we will only use the most basic setup and keep several features disabled (like Elasticsearch
     8 integration, notifications...).
     8 integration, notifications...).
     9 
     9 
    10 See :ref:`install` to get a full description of installation process.
    10 See :ref:`install` to get a full description of installation process.
    11 
    11 
    12 
    12 
    13 To do first
    13 0. Before starting
    14 +++++++++++
    14 ++++++++++++++++++
    15 
    15 
    16 PyAMS relies on Python packages for which you must have system packages available in your environment. These include:
    16 Required packages
    17 
    17 -----------------
    18 * a C/C++ compiler (GCC is fine)
    18 
    19 
    19 PyAMS relies on system and Python packages which you must have been previously installed in your environment.
    20 * a Python 3.5 interpreter with development headers; PyAMS may be compatible with other versions but has only been
    20 
    21   completely tested with this version until now
    21 .. note::
    22 
    22 
    23 * several libraries with their development headers; these include libjpeg, libpng, libfreetype, libxml2 and libxslt
    23     - a C/C++ compiler like **GCC**
    24   (and libpq if you want to use PostgreSQL)
    24     - **Python 3.5*** with development headers; **Cython3** for better optimization of several packages
    25 
    25     - a cache server, like **Redis** or **Memcached**.
    26 * a cache server, like Redis or Memcached.
    26     - Several libraries with their development headers: *libjpeg*, *libpng*, *libfreetype*, *libxml2* and *libxslt*
    27 
    27       (and *libpq* if you want to use PostgreSQL, *libldap* if you want to use LDAP authentication...).
    28 You can also choose to install Cython for better optimization of several packages...
    28 
    29 
    29 * PyAMS may be compatible with other versions but has only been completely tested with this version until now.
    30 On a Debian GNU/Linux environment, required commands may be:
    30 
    31 
    31 On a Debian GNU/Linux:
    32 .. code-block:: bash
    32 
    33 
    33 .. code-block:: bash
    34     # apt-get install python3.5 python3.5-dev
    34 
    35     # apt-get install libjpeg-dev libpng-dev libfreetype6-dev libxml2-dev libxslt1-dev
    35      $ apt-get install python3.5 python3.5-dev
    36     # apt-get install redis-server redis-tools
    36      $ apt-get install cython3
    37     # apt-get install cython3
    37      $ apt-get install redis-server redis-tools
       
    38      $ apt-get install libjpeg-dev libpng-dev libfreetype6-dev libxml2-dev libxslt1-dev
    38 
    39 
    39 
    40 
    40 Initialize virtual environment
    41 Initialize virtual environment
    41 ++++++++++++++++++++++++++++++
    42 ------------------------------
    42 
    43 
    43 We are creating a virtual environment in */var/local/env*; it will include a small set of utilities required to use
    44 We are creating a virtual environment in */var/local/env*
    44 PyAMS templates:
    45 
    45 
    46 .. code-block:: bash
    46 .. code-block:: bash
    47 
    47 
    48     $ mkdir /var/local/
    48     # mkdir /var/local/
    49     $ pip3 install virtualenv
    49     # pip3 install virtualenv
    50     $ virtualenv --python=python3.5 env
    50     # virtualenv --python=python3.5 env
    51     $ source env/bin/activate
    51     # cd env
    52 
    52     # . bin/activate
    53 To use PyAMS templates, the *cookiecutter* tool is required:
    53     (env) # pip3.5 install cookiecutter
    54 
    54 
    55 .. code-block:: bash
    55 
    56 
    56 Create ZODB
    57     (env)$ pip3.5 install cookiecutter
    57 +++++++++++
    58 
    58 
    59 
    59 We are creating a local ZODB using ZEO, based on PyAMS cookiecutter template; several configuration parameters
    60 1. Create ZODB
    60 are required, Python eggs will be stored into */var/local/eggs* directory.
    61 ++++++++++++++
    61 
    62 
    62 **WARNING**: in this quickstart example, ZEO server instance will run as current user and group; for a production
    63 We are creating a local ZODB using a "ZEO server" cookiecutter template.
    63 environment, it's better to use dedicated service user and group!
    64 
    64 
    65 .. tip:: To know more about ZODB storages you can see :ref:`zodb`.
    65 .. code-block:: bash
    66 
    66 
    67 .. note::
    67     (env) # cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/zeo_server
    68 
       
    69     In this example, ZEO server instance will run as current UNIX user and group. For a production
       
    70     environment, it's better to use dedicated service user and group.
       
    71 
       
    72 Run cookiecutter:
       
    73 
       
    74 .. code-block:: bash
       
    75 
       
    76     (env)$ cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/zeo_server
       
    77 
       
    78 
       
    79 Configuration:
       
    80 
       
    81 .. code-block:: bash
       
    82 
    68     pyams_release [latest]:
    83     pyams_release [latest]:
    69     project_name [ZEO_server]: ZEO_pyams
    84     project_name [ZEO_server]: ZEO_pyams
    70     project_slug [zeo_pyams]:
    85     project_slug [zeo_pyams]:
    71     eggs_directory [eggs]: /var/local/eggs
    86     eggs_directory [eggs]: /var/local/eggs    # Python eggs will be stored into */var/local/eggs* directory.
    72     run_user [zeo]: mylogin
    87     run_user [zeo]: mylogin                   # current user ID
    73     run_group [zeo]: mygroup
    88     run_group [zeo]: mygroup                  # current user group
    74     zeo_server_port [8100]:
    89     zeo_server_port [8100]:
    75     zeo_storage [pyams]:
    90     zeo_storage [pyams]:
    76     zeo_pack_report [root@localhost]: email@my-domain.com
    91     zeo_pack_report [root@localhost]: email@my-domain.com
    77     logs_directory [/var/log/zeo/zeo_pyams]:
    92     logs_directory [/var/log/zeo/zeo_pyams]:  # An absolute path is mandatory!!!
    78 
    93 
    79     Your ZEO environment is initialized.
    94     Your ZEO environment is initialized.
    80     To finalize it's creation, just type:
    95     To finalize it\'s creation, just type:
    81     - cd zeo_pyams
    96     - cd zeo_pyams
    82     - python3.5 bootstrap.py
    97     - python3.5 bootstrap.py
    83     - ./bin/buildout
    98     - ./bin/buildout
    84 
    99 
    85     (env) # cd zeo_pyams
   100 
    86 
   101 In *zeo_pyams* folder, execute *bootstrap.py*:
    87     (env) # python3.5 bootstrap.py
   102 
       
   103 .. code-block:: bash
       
   104 
       
   105     (env)$ cd zeo_pyams
       
   106 
       
   107     (env)$ python3.5 bootstrap.py
    88     Creating directory '/var/local/env/zeo_pyams/bin'.
   108     Creating directory '/var/local/env/zeo_pyams/bin'.
    89     Creating directory '/var/local/env/zeo_pyams/parts'.
   109     Creating directory '/var/local/env/zeo_pyams/parts'.
    90     Creating directory '/var/local/env/zeo_pyams/develop-eggs'.
   110     Creating directory '/var/local/env/zeo_pyams/develop-eggs'.
    91     Generated script '/var/local/env/zeo_pyams/bin/buildout'.
   111     Generated script '/var/local/env/zeo_pyams/bin/buildout'.
    92 
   112 
    93     (env) # ./bin/buildout
   113 
       
   114 And then run final *buildout*:
       
   115 
       
   116 .. code-block:: bash
       
   117 
       
   118     (env)$ ./bin/buildout
       
   119 
    94     Installing zodb.
   120     Installing zodb.
    95     Generated script '/var/local/env/zeo_pyams/bin/zeopack'.
   121     Generated script '/var/local/env/zeo_pyams/bin/zeopack'.
    96     Generated script '/var/local/env/zeo_pyams/bin/runzeo'.
   122     Generated script '/var/local/env/zeo_pyams/bin/runzeo'.
    97     Generated script '/var/local/env/zeo_pyams/bin/zeo-nagios'.
   123     Generated script '/var/local/env/zeo_pyams/bin/zeo-nagios'.
    98     Generated script '/var/local/env/zeo_pyams/bin/zeoctl'.
   124     Generated script '/var/local/env/zeo_pyams/bin/zeoctl'.
    99     Installing zdaemon.
   125     Installing zdaemon.
   100     Generated script '/var/local/env/zeo_pyams/bin/zdaemon'.
   126     Generated script '/var/local/env/zeo_pyams/bin/zdaemon'.
   101     Installing zeo_pyams.
   127     Installing zeo_pyams.
   102     zc.zodbrecipes: Generated shell script '/var/local/env/zeo_pyams/etc/init.d/zeo-zeo_pyams'.
   128     zc.zodbrecipes: Generated shell script '/var/local/env/zeo_pyams/etc/init.d/zeo-zeo_pyams'.
   103 
   129 
   104     (env) # ./etc/init.d/zeo-zeo_pyams start
   130 
       
   131 Start the ZEO server:
       
   132 
       
   133 .. code-block:: bash
       
   134 
       
   135     (env)$ ./etc/init.d/zeo-zeo_pyams start
       
   136 
   105     Password:
   137     Password:
   106     .
   138     . . .
   107     daemon process started, pid=26230
   139     daemon process started, pid=26230
   108 
   140 
   109 
   141 
   110 See :ref:`zodb` to know more about ZODB storage alternatives.
   142 2. Create application instance
   111 
   143 ++++++++++++++++++++++++++++++
   112 
   144 
   113 Create application instance
   145 Application instance will be created in */var/local/env/pyams* via another coockiecutter template:
   114 +++++++++++++++++++++++++++
   146 
   115 
   147 .. code-block:: bash
   116 Application instance is created in */var/local/env/pyams* via another template:
   148 
   117 
   149     (env)$ cd /var/local/env
   118 .. code-block:: bash
   150     (env)$ cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/pyams
   119 
   151 
   120     (env) # cd /var/local/env
   152 
   121 
   153 .. tip:: Configuration
   122     (env) # cookiecutter hg+http://hg.ztfy.org/pyams/scaffolds/pyams
   154 
       
   155     1. The variable **$((INSTALL))** is the path to current folder; it will be replaced automatically by cookiecutter
       
   156        after application creation
       
   157     2. You will be invited to setup additional services like **Elasticsearch** but you must install them on
       
   158        your own.
       
   159 
       
   160 
       
   161 .. code-block:: bash
       
   162 
   123     pyams_release [latest]:
   163     pyams_release [latest]:
   124     project_name [PyAMS]:
   164     project_name [PyAMS]:
   125     project_slug [pyams]:
   165     project_slug [pyams]:
   126     virtual_hostname [pyams.mydomain.com]: pyams.example.com
   166     virtual_hostname [pyams.mydomain.com]: pyams.example.com
   127     webapp_name [webapp]:
   167     webapp_name [webapp]:
   128     webapp_port [6543]:
   168     webapp_port [6543]:
   129     eggs_directory [eggs]: /var/local/eggs
   169     eggs_directory [eggs]:
   130     logs_directory [/var/log/apache2]:
   170     logs_directory [$((INSTALL))/var/log]:
   131     run_user [www-data]:
   171     run_user [www-data]:      # user used to run server and write logs
   132     run_group [www-data]:
   172     run_group [www-data]:     # group used to run server and write logs
   133     Select beaker_backend:
   173     Select beaker_backend:
   134     1 - redis
   174         1 - redis
   135     2 - memcached
   175         2 - memcached
   136     Choose from 1, 2 [1]:
   176     Choose from 1, 2 [1]:
   137     beaker_server [127.0.0.1:6379]:
   177     beaker_server [127.0.0.1:6379]:
   138     Select db_type:
   178     Select db_type:
   139     1 - zeo
   179         1 - zeo
   140     2 - relstorage
   180         2 - relstorage
   141     3 - newt
   181         3 - newt
   142     Choose from 1, 2, 3 [1]:
   182     Choose from 1, 2, 3 [1]:
   143     db_host [127.0.0.1]:
   183     db_host [127.0.0.1]:
   144     db_port [8100]:
   184     db_port [8100]:
   145     db_name [pyams]: zeo_pyams
   185     db_name [pyams]: zeo_pyams  # db_name created in step 1
   146     db_username [zeouser]:
   186     db_username []:
   147     db_password []:
   187     db_password []:
   148     zeo_realm [pyams]:
   188     zeo_realm [pyams]:
   149     blobs_dir [$((INSTALL)/var/db/blobs]:
   189     blobs_dir [$((INSTALL)/var/db/blobs]:
   150     use_postgresql [True]: False
   190     use_postgresql [True]: False
   151     use_oracle [False]:
   191     use_oracle [False]:
   167     pyams_ws_notify [127.0.0.1:8081]:
   207     pyams_ws_notify [127.0.0.1:8081]:
   168     lexicon_languages [en:english fr:french]:
   208     lexicon_languages [en:english fr:french]:
   169     extension_package []:
   209     extension_package []:
   170     need_pyams_gis [False]:
   210     need_pyams_gis [False]:
   171     Your server environment is initialized.
   211     Your server environment is initialized.
   172     To finalize it's creation, just type:
   212 
       
   213     To finalize it\'s creation, just type:
   173     - cd pyams
   214     - cd pyams
   174     - python3.5 bootstrap.py
   215     - python3.5 bootstrap.py
   175     - ./bin/buildout
   216     - ./bin/buildout
   176 
   217 
   177     (env) # cd pyams
   218 In the project's *pyams* folder, execute *bootstrap.py*:
   178 
   219 
   179     (env) # python3.5 bootstrap.py
   220 .. code-block:: bash
   180 
   221 
   181     (env) # ./bin/buildout
   222     (env)$ cd pyams
       
   223     (env)$ python3.5 bootstrap.py
   182     Creating directory '/var/local/env/pyams/bin'.
   224     Creating directory '/var/local/env/pyams/bin'.
   183     Creating directory '/var/local/env/pyams/develop-eggs'.
   225     Creating directory '/var/local/env/pyams/develop-eggs'.
   184     Generated script '/var/local/env/pyams/bin/buildout'.
   226     Generated script '/var/local/env/pyams/bin/buildout'.
   185 
   227 
   186     (env) # ./bin/buildout
   228 And run final *buildout*:
   187     ...
   229 
   188     (this may take some time!)
   230 .. code-block:: bash
   189 
   231 
   190 Packages download, compilation and installation can easily take several minutes. Install errors are generally due to
   232     (env)$ ./bin/buildout
   191 missing libraries development headers.
   233 
   192 
   234 
   193 See :ref:`appinstall` to get more detailed information about installation process.
   235 .. note::
   194 
   236 
   195 
   237     Packages download, compilation and installation can easily take several minutes. Install errors are generally due to
   196 Start application
   238     missing libraries development headers.
       
   239 
       
   240 
       
   241 .. tip::
       
   242 
       
   243     See :ref:`appinstall` to get more detailed information about installation process.
       
   244 
       
   245 
       
   246 3. Start application
   197 +++++++++++++++++
   247 +++++++++++++++++
   198 
   248 
   199 Application is ready to run! Just check INI files in *etc* directory (see :ref:`config`) and start the application:
   249 Application is ready to run! Just check INI files in *etc* directory (see :ref:`config`) and start the application:
   200 
   250 
   201 .. code-block:: bash
   251 .. code-block:: bash
   202 
   252 
   203     (env) # ./bin/pyams_upgrade etc/development.ini
   253     (env)$ ./bin/pyams_upgrade etc/development.ini
   204 
   254 
   205     (env) # ./bin/pserve etc/development.ini
   255     (env)$ ./bin/pserve etc/development.ini
   206     ...
   256     ...
   207     Starting server in PID 29335.
   257     Starting server in PID 29335.
   208     Serving on http://0.0.0.0:6543
   258     Serving on http://0.0.0.0:6543
   209 
   259 
   210 Launch a browser and open URL *http://127.0.0.1:6543/admin* to get access to PyAMS management interface; default
   260 
   211 login is "admin/admin", that you may change as soon as possible!
   261 Congrats: PyAMS is running !
       
   262 
       
   263 Launch a browser and open URL http://127.0.0.1:6543/admin to get access to PyAMS management interface.
       
   264 
       
   265 
       
   266 .. warning::
       
   267 
       
   268     By default:
       
   269 
       
   270     - Login: admin
       
   271 
       
   272     - Password: admin
       
   273 
       
   274     **You must change it as soon as possible!**
       
   275