@@ -129,6 +129,103 @@ For a complete list of options you can run::
129129Further information on using the mod_wsgi express version see the main
130130mod_wsgi documentation.
131131
132+ Non standard Apache installations
133+ ---------------------------------
134+
135+ Many Linux distributions have a tendency to screw around with the standard
136+ Apache Software Foundation layout for installation of Apache. This can
137+ include renaming the Apache ``httpd `` executable to something else, and in
138+ addition to potentially renaming it, replacing the original binary with a
139+ shell script which performs additional actions which can only be performed
140+ as the ``root `` user.
141+
142+ In the case of the ``httpd `` executable simply being renamed, the
143+ executable will obviously not be found and mod_wsgi express will fail to
144+ start at all.
145+
146+ In this case you should work out what the ``httpd `` executable was renamed
147+ to and use the ``--httpd-executable `` option to specify its real location.
148+
149+ For example, if ``httpd `` was renamed to ``apache2 ``, you might need to use::
150+
151+ mod_wsgi-express start-server wsgi.py --httpd-executable=/usr/sbin/apache2
152+
153+ In the case of the ``httpd `` executable being replaced with a shell script
154+ which performs additional actions before then executing the original
155+ ``httpd `` executable, and the shell script is failing in some way, you will
156+ need to use the location of the original ``httpd `` executable the shell
157+ script is in turn executing.
158+
159+ Running mod_wsgi express as root
160+ --------------------------------
161+
162+ The primary intention of mod_wsgi express is to make it easier for users
163+ to run up Apache on non privileged ports, especially during the development
164+ of a Python web application. If you want to be able to run Apache using
165+ mod_wsgi express on a privileged port such as the standard port 80 used by
166+ HTTP servers, then you will need to run ``mod_wsgi-express `` as root. In
167+ doing this, you will need to perform additional steps.
168+
169+ The first thing you must do is supply the ``--user `` and ``--group ``
170+ options to say what user and group your Python web application should run
171+ as. Most Linux distrbutions will pre define a special user for Apache to
172+ run as, so you can use that. Alternatively you can use any other special
173+ user account you have created for running the Python web application::
174+
175+ mod_wsgi-express start-server wsgi.py --port=80 \
176+ --user www-data --group www-data
177+
178+ This approach to running ``mod_wsgi-express `` will be fine so long as you
179+ are using a process supervisor which expects the started process to remain
180+ in the foreground and not daemonize.
181+
182+ If however you are directly integrating into the system init scripts where
183+ separate start and stop commands are expected, with the executing process
184+ expected to be daemonized, then a different process is required to setup
185+ mod_wsgi express.
186+
187+ In this case, instead of simply using the ``start-server `` command to
188+ ``mod_wsgi-express `` you should use ``setup-server ``::
189+
190+ mod_wsgi-express start-server wsgi.py --port=80 \
191+ --user www-data --group www-data \
192+ --server-root=/etc/mod_wsgi-express-80
193+
194+ In running this command, it will not actually startup Apache. All it will do
195+ is create the set of configuration files and startup script to be run.
196+
197+ So that these are not created in the default location of a directory under
198+ ``/tmp ``, you should use the ``--server-root `` option to specify where they
199+ should be placed.
200+
201+ Having created the configuration and startup script, to start the Apache
202+ instance you can now run::
203+
204+ /etc/mod_wsgi-express-80/apachectl start
205+
206+ To subsequently stop the Apache instance you can run::
207+
208+ /etc/mod_wsgi-express-80/apachectl stop
209+
210+ You can also restart the Apache instance as necessary using::
211+
212+ /etc/mod_wsgi-express-80/apachectl restart
213+
214+ Using this approach, the original options you supplied to ``setup-server ``
215+ will effectively be cached with the resulting configuration used each time.
216+ If you need to update the set of options, run ``setup-server `` again with
217+ the new set of options.
218+
219+ Note that even taking all these steps, it is possible that running up
220+ Apache as ``root `` using mod_wsgi express may fail on systems where SELinux
221+ extensions are enabled. This is because the SELinux profile may not match
222+ what is being expected for the way that Apache is being started, or
223+ alternatively, the locations that Apache has been specified as being
224+ allowed to access, don't match where the directory specified using the
225+ ``--server-root `` directory was placed. You may therefore need to configure
226+ SELinux or move the directory used with ``--server-root `` to an allowed
227+ location.
228+
132229Using mod_wsgi express with Django
133230----------------------------------
134231
0 commit comments