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