In ubuntu + apache2 + mod_wsgi, configure the demon process to run as a user.

Source: Internet
Author: User

 

This problem took about one afternoon.

Previously, a uliweb application was executed using a user identity. At that time, the uliweb debugging server was used for laziness and then managed using the supervisor. However, it was found that the uliweb debugging server could not be suspended using the supervisor.

Later I remembered that wsgidaemonprocess (mod_wsgi's Apache Directive) had the user group parameter. Therefore, mod_wsgi can be configured as a demon process for execution using a user identity, but there was a problem in trying it out, it is found that although wsgidaemonprocess configures the user group, it still seems that the default user www-data is used for execution. Finally, you can see that there is
Also
Wsgiprocessgroup, just add this configuration.

The specific configuration example is as follows. For example, I want to configure an application MyApp to run on port 2005 of the server using the identity of the user demon,

First, modify/etc/apache2/ports. conf and add:
Namevirtualhost*: 2005
Listen 2005.

Modify/etc/apache2/httpd. conf and add:
<Virtualhost *: 2005>
Servername your_server_name
Wsgidaemonprocess your_server_name user = daemon group = daemon processes = 2 threads = 5
Wsgiprocessgroup your_server_name

Wsgiscriptalias // home/daemon/MyApp/wsgi_handler.py
Errorlog/var/log/apache2/myapp-error_log
Customlog/var/log/apache2/myapp-access_log common
</Virtualhost>

That's all.

However, the strange thing is that, according to the test I used print> SYS. stderr and OS. Environ, I found that www-data was used, but it still works normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.