File: commandline.rst

package info (click to toggle)
libapache2-mod-python 3.5.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,864 kB
  • sloc: python: 7,471; ansic: 7,025; makefile: 296; lex: 246; sh: 212
file content (131 lines) | stat: -rw-r--r-- 4,229 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.. _cmd:

******************************
Command Line Tool - mod_python
******************************

.. _cmd-overview:

Overview of mod_python command
==============================

mod_python includes a command-line tool named ``mod_python``. The
``mod_python`` command exists to facilitate tasks related to
configuration and management of mod_python.

The general syntax for the command is ``mod_python <subcommand> <arguments>``
where ``<subcommand>`` is a separate tool with its own argument requirements.

.. _cmd-subcommands:

mod_python command line tool sub-commands
=========================================

create
------

``create`` sub-command creates a simple Apache configuration and a
skeleton directory structure necessary for placement of configuration,
logs and content. It is meant to be executed only once per lifetime of
a project.

The configuration generated by ``create`` consists of an
:mod:`httpdconf` based version (in Python) which can then be used to
generate an actual Apache configuration (by using the ``genconfig``
subcommand or simply executing the config files itself). The idea is
that the Apache configuration is always generated and the Python
version is the one meant for editing/adjustments.

The ``create`` subcommand will create the necessary files and
directories if they do not exist, but will not overwrite any existing
files or directories only producing a warning when a file or directory
already exists. It will abort if the Python version of the
configuration file already exists.

``create`` requires a single argument: the distination directory,
Apache ``ServerRoot``.

``create`` has the following command options:

.. cmdoption:: --listen

   A string describing the port and optional IP address on which the
   server is to listen for incoming requests in the form
   ``[ip_address:]port`` The argument will be applied to the Apache
   ``Listen`` directive as is and therefore must be syntactically
   compatible with it.

.. cmdoption:: --pythonpath

   A colon (``":"``) separate list of paths to be applied to the
   :ref:`dir-other-pp` directive.

.. cmdoption:: --pythonhandler

   The name of the Python handler to use. Applied to the
   :ref:`dir-handlers-ph` directive.

.. cmdoption:: --pythonoption

   An option to be specified in the configuration. Multiple options
   are alowed. Applied to the :ref:`dir-other-po` directive.

.. _cmd-sub-create-example:

genconfig
---------

This sub-command exists to facilitate re-generation of an Apache
configuration from a Python-based one. All it does is run the script,
but its use is recommended because the mod_python command will execute
the correct version of Python under which mod_python was initially
compiled. Example::

   mod_python genconfig /path/to/server_root/httpd_conf.py > /path/to/server_root/httpd.conf

start
-----

Starts an Apache instance. Requires a single argument, the path to
Apache configuration file.

stop
----

Stops an Apache instance (using graceful-stop). Requires a single
argument, the path to Apache configuration file.

restart
-------

Stops an Apache instance (using graceful). Requires a single argument,
the path to Apache configuration file.

version
-------

This sub-command prints out version and location information about
this mod_python installation, the Apache HTTP Server and Python used
when building this mod_python instance.

Example
-------

To create an Apache instance with all the required directories for a
WSGI application which is located in ``/path/to/myapp`` and defined in
``/path/to/myapp/myapp/myapp/wsgi.py``, run the following::

   mod_python create /path/to/new/server_root \
       --pythonpath=/path/to/my/app \
       --pythonhandler=mod_python.wsgi \
       --pythonoption="mod_python.wsgi.application myapp.wsgi::application"

The above example will create a Python-based configuration in
``/path/to/new/server_root/conf/http_conf.py`` which is a simple
Python script. When executed, the output of the script becomes an
Apache configuration (``create`` will take care of generating the
first Apache config for you).

You should be able to run this Apache instance by executing::

   mod_python start /path/to/new/server_root/conf/httpd.conf