Restarting apache as www data using perl

I am working on a webpage that, after certain events, must restart the Apache server it is running on to update some files. I tried adding www data to the sudoers file:

www-data ALL=(ALL) NOPASSWD: /etc/init.d/apache2 start, /etc/init.d/apache2 stop, /etc/init.d/apache2 restart, /sbin/services apache2 restart

but when I try to restart apache, I get the following:

sudo -u www-data /etc/init.d/apache2 restart
Restarting web server apache2                                                                                                            (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

When I looked online, I found that people seemed to be against www data restarting apache, and I could not find anything, suggesting how I would do it if I wanted to ignore warnings for this particular case. If this is not possible, what would be a simple alternative way to restart the apache webpage? I assume that the site is private and secure and will not be used by cybercriminals, and I believe that this is true, given the circumstances in which I am located. thank you for your time

+5
source share
2 answers

Initialization scripts can / should only be run as root (at least on my standard Debian this is).

Apache- ( ) setuid ( ), .

+1

root -:

sudo /etc/init.d/apache2 restart

apache www-data.

www- sudoers, , www-data , - www-data, .

0

All Articles