I want to restart the apache server using url.
I am using cgi-bin shell script to do so but I am not able to do it.
I have created a file apache and put it in /var/www/cgi-bin.
I have written following code in the file apache.
Code:
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Demo</title></head><body>"
service httpd restart
echo "</body></html>"
but when I execute the file in the browser using
Code:
http://server_ip/cgi-bin/apache
it gives me following output on the web page
Code:
Stopping httpd: [FAILED] Starting httpd:
I have updated /etc/sudoers file and put following content in it
Code:
www-data ALL=NOPASSWD:/sbin/service httpd restart
but I am not able to restart apache using url.
I can execute only commands which do not require sudo.
I want to restart apache using web url. Please help me.
Thanks a lot !!!