J
J
juju12015-08-08 06:05:31
PHP
juju1, 2015-08-08 06:05:31

How to reload Apache from php?

How to soft reload Apache2 from php?
I found a solution that worked for someone as they write, but it does not work for me
<?php exec('apachectl -k graceful'); ?>

  1. PHP is not running as root.
  2. But the script above tested from under the root, did not work.
  3. I also want to find a way to reload it from php by passing the password.
  4. Or create a .sh (never done) script on the server that can be run from php without a password. If I may.
  5. Or any other correct way in your opinion.

Dear, I will be very grateful for the right direction and help in this not an easy issue.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
svd71, 2015-08-08
@juju1

I join the Arhimed96 nonsense - how to cut the branch on which you sit?
But everything is possible. One of many solutions: To do this, you need to write a shell script with a reboot and give it permission to run with sudo for the www-data user in the /etc/sudoer file. Type in the apache search engine www-data sudoer

V
Vyacheslav Barsukov, 2015-08-08
@slavabars

If php is not running as root - no way.
Option - we make a listener and run it as root, and we already give him commands to reboot.
The most important crutch - we write sh with a cycle and sleep every 5 seconds, which checks the file /tmp/apache_reboot for 1.
If the file is 0 - we fall asleep for 5 seconds, if 1 - we do a reboot and change 1 to 0.

V
vladimir percov, 2015-08-08
@Arhimed96

The answer will be ridiculous, like the question itself, but you can listen to some port through a sh-script (launched as root), when accessed with a password, Apache will reboot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question