I need my Django app to be able to restart the Apache server running it. I’m using mod_python.
Which is the easiest way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only way this would be possible is if you gave your Django application root permissions, which is horribly unsafe. But, assuming that your app is running as root, you can run
Or whatever command your distribution has for restarting Apache. If the Django app is not root, you may be able to run it with
sudousing the pexpect python library.Note that this way requires you to give the apache user the ability to run
sudowhich is also insecure. In general, I can’t see a secure way to accomplish this.